-- 文件名: SweepAll.lua
-- 作者: 2100
-- 日期: 2024-09-16
-- 用途: 一键扫荡日常任务
-- 脚本网址: https://gitee.com/liqy306/fknsg-sweep-script

local version = "28.62" -- 版本

module("SweepAll", package.seeall)

require "script/network/RequestCenter"
require "script/network/Network"
require "script/model/user/UserModel"
require "script/utils/TimeUtil"
require "script/ui/item/ItemUtil"
require "script/ui/tip/AnimationTip"
require "script/utils/extern"
require "script/model/DataCache"
require "script/ui/rechargeActive/ActiveCache"
require "script/model/utils/ActivityConfigUtil"
require "script/ui/copy/CopyUtil"
require "script/ui/hero/HeroPublicUI"


local timeScale = 1 -- 时间倍率，数值越小越快，中间等待时间会乘上这个数值

local finish_table = {}-- 记录今日已完成任务
local default_value = {}-- 参数设置

local _bgLayer = nil
local mainSeqAct = nil -- 扫荡任务执行函数列表
local alertLayer = nil -- 任务窗口界面
local sweeping = 0 -- 是否正在扫荡
local server_id = UserModel.getServerId()
local pid = UserModel.getPid()
function getVersion()
    return version
end
function readGlobalValue(isShowTip)
    local server_id = UserModel.getServerId()
    local pid = UserModel.getPid()
    
    -- 默认全局配置，会被global.def.txt覆盖
    default_value["sevenslottery_lottery"] =        1       --七星台抽卡次数
    default_value["sevenslottery_lottery_gold"] =   0       --七星台是否允许使用金币抽卡，1表示允许，0表示不允许
    default_value["godbless_bless"] =               1       --神器台抽卡抽卡次数
    default_value["godbless_bless_gold"] =          0       --神器台是否允许使用金币抽卡，1表示允许，0表示不允许
    default_value["forfmhero_draw"] =               2       --普通名将抽卡次数
    default_value["forfmhero_draw_gold"] =          0       --普通名将是否允许使用金币抽卡，1表示允许，0表示不允许
    default_value["forfmherobt_draw"] =             2       --高级名将抽卡次数
    default_value["forfmherobt_draw_gold"] =        0       --高级名将是否允许使用金币抽卡，1表示允许，0表示不允许
    default_value["houjunfactory_lottery"] =        2       --后军台抽卡次数
    default_value["houjunfactory_lottery_gold"] =   1       --后军台是否允许使用金币抽卡，1表示允许，0表示不允许
    default_value["tongque_lottery"] =              2       --铜雀台抽卡次数
    default_value["tongque_lottery_gold"] =         1       --铜雀台是否允许使用金币抽卡，1表示允许，0表示不允许
    default_value["biography_roll"] =               1       --藏书阁寻书次数

    default_value["throne_worship"] =               1       --逐鹿中原膜拜,参数1表示第一个银币膜拜，取值范围1~3,
    default_value["guild_contribute"] =             1       --军团建设，1（初级建设）~5（究极建设）

    default_value["worldcompete_buyAtkNum"] =       10      --跨服比武挑战次数购买
    default_value["moon_addAttackNum2"] =           1       --水月之境梦魇副本购买次数
    default_value["godtower_buyNum"] =              1       --通天塔购买次数
    default_value["magicpetcopy_buyAtkNum"] =       0       --神兽副本购买次数
    default_value["shop_buyGoods1"] =               1       --道具商店购买体力丹个数，0~18
    default_value["shop_buyGoods2"] =               1       --道具商店购买耐力丹个数，0~40
    default_value["shop_buyGoods18"] =              0       --道具商店购买666大礼包，0~1
    default_value["sortie_buyAtkNum"] =             2       --名将突围购买次数
    default_value["sortie_openBoxNum"] =            4       --名将突围指定等级（每关购买次数）的宝箱购买次数，1~4
    default_value["sortie_openBoxLv"] =             1       --名将突围宝箱每关购买次数，0:免费,1:50金币,2:100金币,3:200金币

    default_value["reward_task_currency"] =         200     --悬赏任务普通悬赏币小于这个数值的任务会直接刷新，可选0,40,80,100,120,160,200,240,300,400,500,600,1000

    default_value["worldplace_occuOther"] =         140     --幻化结缘修炼自动选择最低加成
    default_value["festivalActReward_DianJiangTai"]=1       --狂欢点将台任务是否允许在第三天一键完成剩余次数（如果没有道具，将会直接花费金币），1表示允许，0表示不允许
    --神秘商店物品id表（仅用在神秘商店）
    --502170 属性阵旗碎片包
    --502171 铸造材料包
    --502172 阵旗强化令
    --502173 5星武将包
    --502174 13资质武将包
    --502175 经验金马碎片一
    --502176 经验金书碎片一
    --502177 紫古宝碎片
    --502178 橙古宝碎片
    --502182 红古宝碎片
    --502183 金古宝碎片
    default_value["mysteryshop_buy_item_id"] =      {502183,502172}      --神秘商店购买物品id，默认购买金古宝碎片和阵旗强化令
    default_value["gcopy_sweep"] =                  {["主限"]="蜀",["副限"]="群",["充值"]="群",["热卖"]="蜀",["酒馆"]="蜀"} --星魂副本优先使用系统勾选缓存数据，没有使用此处默认设置
    
    --2025.3.27 V21.34 添加
    default_value["guildcopy_buyBoss"] =            0       --攻城BOSS购买次数
    default_value["guildcopy_addAtkNum"] =          0       --攻城副本购买次数
    --2025.4.8 V22.35 添加
    default_value["pass_dealChest"] =               2       --过关斩将宝箱购买次数(0~8)
    default_value["pass_sweep"] =                   1       --过关斩将扫荡购买宝箱次数(0~8)
    --2025.4.9 V23.38 添加
    default_value["worldrewardtask_quality"] =      6       --跨服悬赏出现一键完成的最小任务品质1~2白，3绿，4蓝，5紫，6橙，7红

    default_value["worldguild_reward"] =            3       --0~3，跨服军团祈福次数
    default_value["worldguild_contribute"] =        5       --1~5，跨服军团贡献，1（初级建设）~5（顶极建设）

    local path = CCFileUtils:sharedFileUtils():getWritablePath().. "Resources/script/ui/main/def/global.def.txt"
    -- 扫荡脚本所在文件夹
    if (CCFileUtils:sharedFileUtils():isFileExist(path) ~= true) then
    --没有就使用全局配置
        if(isShowTip~=false)then
            showTip(path.." 配置文件不存在，使用默认配置")
        end
        -- printT(default_value)
        return
    end
    prints("当前配置文件路径："..path)
    io.input(path)
    local Buffer = io.read("*all")
    local config = string.split(Buffer, "\n")
    for k, v in pairs(config) do
        if (string.len(v) ~= 0) then
            local name_value = string.split(v, "=")
            if(table.count(name_value)>=2)then
                if(name_value[1]=="mysteryshop_buy_item_id")then
                    local value = string.gsub(name_value[2],"，",",")
                    default_value[name_value[1]] = string.split(value, ",")
                elseif(name_value[1]=="gcopy_sweep")then
                    local value = string.gsub(name_value[2],"，",",")
                    local type_country = string.split(value, ",")
                    for k,v in pairs(type_country)do
                        local a = string.split(v, "-")
                        default_value[name_value[1]][a[1]] = a[2]
                    end
                else
                    default_value[name_value[1]] = tonumber(name_value[2])
                end
            end
        end
    end
    if(isShowTip~=false)then
        showTip("读取global.def.txt配置成功")
    end
    -- printT(default_value)
end
function readDefaultValue(isShowTip)
    local server_id = UserModel.getServerId()
    local pid = UserModel.getPid()

    readGlobalValue(isShowTip)
    local path = CCFileUtils:sharedFileUtils():getWritablePath().. "Resources/script/ui/main/def/"..server_id .. " " .. pid .. ".def.txt"
    -- 扫荡脚本所在文件夹
    if (CCFileUtils:sharedFileUtils():isFileExist(path) ~= true) then
        if(isShowTip~=false)then
            showTip(path.." 配置文件不存在，使用全局配置")
        end
        -- printT(default_value)
        return
    end
    prints("当前配置文件路径："..path)
    io.input(path)
    local Buffer = io.read("*all")
    local config = string.split(Buffer, "\n")
    for k, v in pairs(config) do
        if (string.len(v) ~= 0) then
            local name_value = string.split(v, "=")
            if(table.count(name_value)>=2)then
                if(name_value[1]=="mysteryshop_buy_item_id")then
                    local value = string.gsub(name_value[2],"，",",")
                    default_value[name_value[1]] = string.split(value, ",")
                elseif(name_value[1]=="gcopy_sweep")then
                    local value = string.gsub(name_value[2],"，",",")
                    local type_country = string.split(value, ",")
                    for k,v in pairs(type_country)do
                        local a = string.split(v, "-")
                        default_value[name_value[1]][a[1]] = a[2]
                    end
                else
                    default_value[name_value[1]] = tonumber(name_value[2])
                end
            end
        end
    end
    if(isShowTip~=false)then
        showTip("读取"..server_id .. " " .. pid .. ".def.txt配置成功")
    end
    -- printT(default_value)
end

function isBagFull(isShowAlert,callBack)
    if(ItemUtil.isBagFull(isShowAlert,callBack))then
        return true
    end
    if(HeroPublicUI.showHeroIsLimitedUI(isShowAlert,callBack))then
        return true
    end
    return false
end

--获取星期几
function getWeekNum()
    --当前是星期几
    t = os.time()
    local weekNum = os.date("*t", t).wday - 1
    if weekNum == 0 then
        weekNum = 7
    end
    return weekNum;
end

--给周几和一个时间如:153000，得到周几15:30:00的时间戳
function getWeekIntervalByTime(weekday,time)
    local curTime = TimeUtil.getSvrTimeByOffset()
    local weekdayTime = curTime+(-getWeekNum(curTime)+weekday)*86400
    local temp = os.date("*t",weekdayTime)
	time = string.format("%06d", time)

	local h,m,s = string.match(time, "(%d%d)(%d%d)(%d%d)" )
	local timeString = temp.year .."-".. temp.month .."-".. temp.day .." ".. h ..":".. m ..":".. s
    local timeInt = TimeUtil.getIntervalByTimeString(timeString)
    return timeInt
end

function init()
    server_id = UserModel.getServerId()
    pid = UserModel.getPid()
    _bgLayer = nil
    mainSeqAct = nil
    default_value = {} -- 清空任务默认设置次数缓存
    finish_table = {} -- 清空已完成任务缓存
end

local isLog = true -- 是否输出日志，true:输出，false:不输出
-- 输出table信息
function printT(x)
    if(isLog)then
        printTable1(x)
    end
end



-- 日志输出功能，已经将文件中的所有日志输出整合到write_log函数中，取消日志输出功能只需注删除或注释write_log中的代码即可
function write_log(string)
    if(isLog)then
        if (CCFileUtils:sharedFileUtils():isFileExist(CCFileUtils:sharedFileUtils():getWritablePath().. "Resources/script/ui/main/log/") ~= true) then
            local ret = os.execute("mkdir "..CCFileUtils:sharedFileUtils():getWritablePath().. "Resources/script/ui/main/log/")
            if ret ~= 0 then
                showTip("文件夹创建失败")
                return false
            else
                showTip("文件夹创建成功")
            end
        end
        local str =
            "\nLog output date: " .. TimeUtil.getTimeFormatYMDHMS(TimeUtil.getSvrTimeByOffset()) .. "\n" .. string .. "\n"
        local path = CCFileUtils:sharedFileUtils():getWritablePath().. "Resources/script/ui/main/log/"..server_id.." "..pid.." fknsg.log"
        local file = io.open(path, "a+")
        file:write(str)
        file:close()
    end
end
-- 显示文字提示
function showTip(_str)
    local str = tostring(_str)
    require "script/ui/tip/AnimationTip"
    -- 调用系统显示文字提示功能
    AnimationTip.showTip(str)
    -- 以下为添加的日志输出功能
    write_log(str)
end


-- 输出函数，输出结果会保存到日志中
function prints(_str)
    local str = tostring(_str)
    print(str)
    write_log(str)
end


--↓↓↓↓↓↓↓↓↓↓↓↓↓↓活动详细信息解析工具函数↓↓↓↓↓↓↓↓↓↓↓↓↓↓

-- 递归生成物品信息字符串，index表示礼包递归层数，-1表示不限制递归层数
function printItem(items,index)
    print("printItem"..index)
    local ret = ""
    local print_index = index or 0
    if(print_index==0)then
        print("items_len: " .. #items)
        if(#items>0)then
            print(items[1].name.."*"..items[1].num)
        end
    end
    if(#items==0)then
        local item = items
        ret = ret..item.name.."*"..item.num
        if(print_index ~= 0)then
            if(item.choose==1)then
                ret = ret.."(获得所有:"
                for j=1,#item.content do
                    local choose = item.content[j]
                    if(choose.choose~=0)then
                        ret=ret..printItem(choose,print_index-1)
                    else
                        ret=ret..choose.name.."*"..choose.num..", "
                    end
                end
                ret = ret..")"
            elseif (item.choose==2)then
                ret = ret.."(任选一个:"
                for j=1,#item.content do
                    local choose = item.content[j]          
                    if(choose.choose~=0)then
                        ret=ret..printItem(choose,print_index-1)
                    else
                        ret=ret..choose.name.."*"..choose.num..", "
                    end
                end
                ret = ret..")"
            end
        end
        ret = ret..", "
        return ret
    end
    for i=1,#items do
        local item = items[i]
        ret = ret..item.name.."*"..item.num
        if(print_index ~= 0)then
            if(item.choose==1)then
                ret = ret.."(获得所有:"
                for j=1,#item.content do
                    local choose = item.content[j]
                    if(choose.choose~=0)then
                        ret=ret..printItem(choose,print_index-1)
                    else
                        ret=ret..choose.name.."*"..choose.num..", "
                    end
                end
                ret = ret..")"
            elseif (item.choose==2)then
                ret = ret.."(任选一个:"
                for j=1,#item.content do
                    local choose = item.content[j]        
                    if(choose.choose~=0)then
                        ret=ret..printItem(choose,print_index-1)
                    else
                        ret=ret..choose.name.."*"..choose.num..", "
                    end
                end
                ret = ret..")"
            end
        end
        ret = ret..", "
    end
    return ret
end
--index表示礼包递归层数，-1表示不限制递归层数
function print3TupleNum(p3TupleStr,index)
    print("print3TupleNum"..index)
    local items = get3TupleNum(p3TupleStr)
    return printItem(items,index)
end

function getAll3TupleNum(p3TupleStr_list)
    print("getAll3TupleNum "..type(p3TupleStr_list))
    local ret = {}
    for i=1,#p3TupleStr_list do
        p3TupleStr=p3TupleStr_list[i]
        table.insert(ret,get3TupleNum(p3TupleStr))
    end 
    return ret
end

function get3TupleNum(p3TupleStr)
    print("get3TupleNum "..type(p3TupleStr))
    if(type(p3TupleStr)=="table")then
        return getAll3TupleNum(p3TupleStr)
    end
    if(type(p3TupleStr)=="string")then
        if(string.find(p3TupleStr,",")~=nil)then
            local p3TupleStr_list = string.split(p3TupleStr,",")
            return getAll3TupleNum(p3TupleStr_list)
        end
    end
    local ret = {["type"]="",["name"]="",["num"]="0",["choose"]=0,["content"]={}}
	local itemInfo = string.split(p3TupleStr, "|")
	local itemType = tonumber(itemInfo[1])
    local itemId  = tonumber(itemInfo[2])
    local itemNum  = tonumber(itemInfo[3])
    ret.num = itemNum
	if itemType == 1 then
        -- 银币
        ret.type = "银币"
        ret.name = "银币"
    elseif itemType == 2  then
        -- 将魂
        ret.type = "将魂"
        ret.name = "将魂"
    elseif itemType == 3  then
        -- 金币
        ret.type = "金币"
        ret.name = "金币"
    elseif itemType == 4 then
        -- 体力(wu)
        ret.type = "体力(wu)"
        ret.name = "体力"
    elseif itemType == 5  then
        -- 耐力(wu)
        ret.type = "耐力(wu)"
        ret.name = "耐力"
    elseif itemType == 6  then
    	--物品
        d = ItemUtil.getItemById(itemId)
		ret.type = "单个物品"
        ret.name = d.name
        if(d.award_item_id~=nil and d.award_item_id~="")then
            ret.choose = 1
            ret.content = get2TupleNum(string.split(d.award_item_id,","))
        elseif(d.choose_items~=nil and d.choose_items~="")then
            ret.choose = 2
            ret.content = get3TupleNum(string.split(d.choose_items,","))
        end
    elseif itemType == 7  then
        --多个物品
        d = ItemUtil.getItemById(itemId)
		ret.type = "多个物品"
        ret.name = d.name
        if(d.award_item_id~=nil and d.award_item_id~="")then
            print("award_item_id"..d.award_item_id)
            ret.choose = 1
            ret.content = get2TupleNum(string.split(d.award_item_id,","))
        elseif(d.choose_items~=nil and d.choose_items~="")then
            print("choose_items"..d.choose_items)
            ret.choose = 2
            ret.content = get3TupleNum(string.split(d.choose_items,","))
        end
    elseif itemType == 8  then
        -- 等级*银币(wu)
        ret.type = "等级*银币(wu)"
        ret.name = "银币"
    elseif itemType == 9  then
        -- 等级*将魂(wu)
        ret.type = "等级*将魂(wu)"
        ret.name = "将魂"
    elseif itemType == 10 then
        -- 单个英雄 类型10 类型id|物品数量默认1|英雄id  以前约定特殊处理(wu)
        ret.type = "单个英雄"
        require "db/DB_Heroes"
        ret.name = DB_Heroes.getDataById(itemId).name
    elseif itemType == 11  then
        -- 魂玉
        ret.type = "魂玉"
        ret.name = "魂玉"
    elseif itemType == 12   then
        -- 声望
        ret.type = "声望"
        ret.name = "声望"
    elseif itemType == 13  then
        -- 多个英雄(wu)
        ret.type = "多个英雄(wu)"
        require "db/DB_Heroes"
        ret.name = DB_Heroes.getDataById(itemId).name
    elseif itemType == 14  then
        -- 宝物碎片
        ret.type = "宝物碎片"
        ret.name = "宝物碎片"
    elseif itemType == 15  then
        -- 军团个人贡献
        ret.type = "军团个人贡献"
        ret.name = "军团个人贡献"
    elseif itemType == 16  then
        -- 军团建设度
        ret.type = "军团建设度"
        ret.name = "军团建设度"
    elseif itemType == 17  then
        -- 比武荣誉
        ret.type = "比武荣誉"
        ret.name = "比武荣誉"
    elseif itemType == 18  then
    	--粮草
        ret.type = "粮草"
        ret.name = "粮草"
    elseif itemType == 19 then
    	-- 神兵令
        ret.type = "神兵令"
        ret.name = "神兵令"
    elseif itemType == 20 then
    	--战功
        ret.type = "将魂"
        ret.name = "将魂"
    elseif itemType == 21  then
    	-- 天工令
        ret.type = "天工令"
        ret.name = "天工令"
    elseif itemType == 22  then
    	--争霸令
        ret.type = "争霸令"
        ret.name = "争霸令"
    elseif itemType == 23 then
    	--炼狱令
        ret.type = "炼狱令"
        ret.name = "炼狱令"
    elseif itemType == 24 then
    	-- 名望
        ret.type = "名望"
        ret.name = "名望"
    elseif itemType == 25  then
    	-- 跨服荣誉
        ret.type = "跨服荣誉"
        ret.name = "跨服荣誉"
	elseif itemType == 26  then
		-- 将星 
        ret.type = "将星"
        ret.name = "将星"
    elseif itemType == 27 then
   		-- 国战积分
        ret.type = "国战积分"
        ret.name = "国战积分"
   	elseif itemType == 28  then
   		-- 兵符积分
        ret.type = "兵符积分"
        ret.name = "兵符积分"
    elseif itemType == 29 then
   		-- 科技图纸
        ret.type = "科技图纸"
        ret.name = "科技图纸"
    elseif itemType == 30 then
   		-- 试炼币
        ret.type = "试炼币"
        ret.name = "试炼币"
    elseif itemType == 31 then
   		-- 星魄
        ret.type = "星魄"
        ret.name = "星魄"
    elseif itemType == 32 then
   		-- 经验
        ret.type = "经验"
        ret.name = "经验"
    elseif itemType == 33 then
   		-- 经验*等级
        ret.type = "经验*等级"
        ret.name = "经验"
    elseif itemType == 34  then
   		-- 悬赏币  
        ret.type = "悬赏币"
        ret.name = "悬赏币"
    elseif itemType == 35  then
   		-- 魔王币  
        ret.type = "魔王币"
        ret.name = "魔王币"
    elseif itemType == 36  then
   		-- 军工
        ret.type = "军功"
        ret.name = "军功"
    elseif itemType == 37  then
   		-- 功绩
        ret.type = "功绩"
        ret.name = "功绩"
    elseif itemType == 38  then
   		--原石数量
        ret.type = "原石数量"
        ret.name = "原石数量"
   	elseif itemType == 39  then
   		--荣耀积分
        ret.type = "荣耀积分"
        ret.name = "荣耀积分"
    elseif itemType == 40  then
        --抽奖券
        ret.type = "抽奖券"
        ret.name = "抽奖券"
   	elseif itemType == 41  then
   		--竹简积分
        ret.type = "竹简积分"
        ret.name = "竹简积分"
   	elseif itemType == 42  then
   		--每日任务积分
        ret.type = "每日任务积分"
        ret.name = "每日任务积分"
   	elseif itemType == 43  then
   		--威名
        ret.type = "威名"
        ret.name = "威名"
   	elseif itemType == 44  then
   		--群雄争霸令
        ret.type = "群雄争霸令"
        ret.name = "群雄争霸令"
   	elseif itemType == 45  then
   		--神器成就点数
        ret.type = "神器成就点数"
        ret.name = "神器成就点数"
   	elseif itemType == 46  then
   		--跨服悬赏币
        ret.type = "跨服悬赏币"
        ret.name = "跨服悬赏币"
   	elseif itemType == 47  then
   		--跨服悬赏积分
        ret.type = "跨服悬赏积分"
        ret.name = "跨服悬赏积分"
   	elseif itemType == 48  then
   		--66币
        ret.type = "66币"
        ret.name = "66币"
   	elseif itemType == 49  then
   		--贮金
        ret.type = "贮金"
        ret.name = "贮金"
   	elseif itemType == 50  then
   		--盛典金币
        ret.type = "盛典金币"
        ret.name = "盛典金币"
   	elseif itemType == 51  then
   		--盛典银币
        ret.type = "盛典银币"
        ret.name = "盛典银币"
   	elseif itemType == 52  then
   		--神兽试炼币
        ret.type = "神兽试炼币"
        ret.name = "神兽试炼币"
    elseif itemType == 53  then
   		--高级悬赏币
        ret.type = "高级悬赏币"
        ret.name = "高级悬赏币"
    elseif itemType == 54  then
   		--幻化修炼币
        ret.type = "幻化修炼币"
        ret.name = "幻化修炼币"
    elseif itemType == 55  then
   		--特惠礼券
        ret.type = "特惠礼券"
        ret.name = "特惠礼券"
    elseif itemType == 56  then
   		--九周年经验
        ret.type = "九周年经验"
        ret.name = "九周年经验"
    elseif itemType == 57  then
   		--红颜精魄
        ret.type = "红颜精魄"
        ret.name = "红颜精魄"
    elseif itemType == 58  then
   		--点券
        ret.type = "点券"
        ret.name = "点券"
    elseif itemType == 59  then
   		--锦鲤号
        ret.type = "锦鲤号"
        ret.name = "锦鲤号"
    elseif itemType == 99  then
   		--逐鹿中原积分
        ret.type = "逐鹿中原积分"
        ret.name = "逐鹿中原积分"
   	else
    end
    return ret
end


function getAll2TupleNum(p2TupleStr_list)
    local ret = {}
    for i=1,#p2TupleStr_list do
        p2TupleStr=p2TupleStr_list[i]
        table.insert(ret,get3TupleNum("7|"..p2TupleStr))
    end 
    return ret
end

function get2TupleNum(p2TupleStr)
    if(type(p2TupleStr)=="table")then
        return getAll2TupleNum(p2TupleStr)
    end
    if(type(p2TupleStr)=="string")then
        if(string.find(p2TupleStr,",")~=nil)then
            local p2TupleStr_list = string.split(p2TupleStr,",")
            return getAll2TupleNum(p2TupleStr_list)
        end
    end
    return get3TupleNum("7|"..p2TupleStr)
end

function getAll4TupleNum(p4TupleStr_list)
    local ret = {}
    for i=1,#p4TupleStr_list do
        p4TupleStr=p4TupleStr_list[i]
        local itemInfo = string.split(p4TupleStr,"|")
        if(ret[tonumber(itemInfo[1])]==nil)then
            ret[tonumber(itemInfo[1])]={}
        end
        table.insert(ret[tonumber(itemInfo[1])],get3TupleNum(itemInfo[2].."|"..itemInfo[3].."|"..itemInfo[4]))
    end 
    return ret
end

function get4TupleNum(p4TupleStr)
    if(type(p4TupleStr)=="table")then
        return getAll4TupleNum(p4TupleStr)
    end
    if(type(p4TupleStr)=="string")then
        if(string.find(p4TupleStr,",")~=nil)then
            local p4TupleStr_list = string.split(p4TupleStr,",")
            return getAll4TupleNum(p4TupleStr_list)
        end
    end
    local ret={}
    local itemInfo=string.split(p4TupleStr,"|")
    if(ret[tonumber(itemInfo[1])]==nil)then
        ret[tonumber(itemInfo[1])]={}
    end
    table.insert(ret[tonumber(itemInfo[1])],get3TupleNum(itemInfo[2].."|"..itemInfo[3].."|"..itemInfo[4]))
    return ret
end

function print4TupleNum(p4TupleStr,index,key)
    local ret=""
    local items = get4TupleNum(p4TupleStr)
    local find_key = nil
    if(key~=nil)then
        find_key = key
    end
    for k,v in pairs(items) do
        if(find_key)then
            if(k==find_key)then
                ret = ret..k..":"..printItem(v,index)
                break
            end
        else
            ret = ret..k..":"..printItem(v,index).."\n"
        end
    end
    return ret
end

-- ↓↓↓↓↓↓↓↓↓↓↓↓↓↓表格打印函数，结果会输出到文件↓↓↓↓↓↓↓↓↓↓↓↓↓↓
function GetTalbleMapLen(tab)
    local len = 0
    for _, v in pairs(tab) do
        if v then
            len = len + 1
        end
    end
    return len
end

-- key值格式化
local function formatKey(key)
    local t = type(key)
    if t == "number" then
        return "[" .. key .. "]"
    elseif t == "string" then
        local n = tonumber(key)
        if n then
            return "[" .. key .. "]"
        end
    end
    return key
end

-- 栈
local function newStack()
    local stack = {
        tableList = {}
    }
    function stack:push(t)
        table.insert(self.tableList, t)
    end
    function stack:pop()
        return table.remove(self.tableList)
    end
    function stack:contains(t)
        for _, v in ipairs(self.tableList) do
            if v == t then
                return true
            end
        end
        return false
    end
    return stack
end

-- 输出打印table表 函数
function printTable1(...)
    local args = {...}
    for k, v in pairs(args) do
        local root = v
        if type(root) == "table" then
            local temp = {"------------------------ printTable start ------------------------\n",
                          "local tableValue" .. " = {\n"}
            local stack = newStack()
            local function table2String(t, depth)
                stack:push(t)
                if type(depth) == "number" then
                    depth = depth + 1
                else
                    depth = 1
                end
                local indent = ""
                for i = 1, depth do
                    indent = indent .. "    "
                end
                for k, v in pairs(t) do
                    local key = tostring(k)
                    local typeV = type(v)
                    if typeV == "table" then
                        if key ~= "__valuePrototype" then
                            if stack:contains(v) then
                                table.insert(temp, indent .. formatKey(key) .. " = {检测到循环引用!},\n")
                            else
                                table.insert(temp, indent .. formatKey(key) .. " = {\n")
                                table2String(v, depth)
                                table.insert(temp, indent .. "},\n")
                            end
                        end
                    elseif typeV == "string" then
                        table.insert(temp, string.format("%s%s = \"%s\",\n", indent, formatKey(key), tostring(v)))
                    else
                        table.insert(temp, string.format("%s%s = %s,\n", indent, formatKey(key), tostring(v)))
                    end
                end
                stack:pop()
            end
            table2String(root)
            table.insert(temp, "}\n------------------------- printTable end -------------------------")
            write_log(table.concat(temp))
        else
            write_log("----------------------- printString start ------------------------\n" .. tostring(root) ..
                          "\n------------------------ printString end -------------------------")
        end
    end
end


-- 定时器函数
-- node：节点，必填，一般为CCDirector:sharedDirector():getRunningScene()
-- callback：调用函数，必填
-- delay：延迟启动时间，单位秒，默认为0
-- repeat_num：重复次数，默认为1次
function schedule(node, callback, delay, repeat_num)
    local run_num = repeat_num or 0
    if (run_num == 0) then
        run_num = 1
    end
    if(node==nil)then
        node = CCDirector:sharedDirector():getRunningScene()
    end
    local delay = delay or 0
    delay = delay * timeScale or 0
    local actionArray = CCArray:create()
    local dely = CCDelayTime:create(delay)
    for i = 1, run_num do
        actionArray:addObject(dely)
        actionArray:addObject(CCCallFunc:create(callback))
    end
    local seq = CCSequence:create(actionArray)
    node:runAction(seq)
    return seq
end


-- 滑动进度条数量选择对话框
-- callback：确认按钮回调函数，参数为选择的物品数量
-- itemId：使用的物品id，当id为nil时使用itemName和itemNum
-- freeNum：免费次数（为神秘商店刷新预留）
-- goldNum：金币次数（为神秘商店刷新预留）
-- default：初始数值
-- desc：下面文本描述
-- _itemName：使用的物品名称
-- _itemNum：使用的物品数量
-- minNum：最小使用数量，默认为0
-- ChangeCb：更改数量时回调函数，参数为下面的提示文本对象和选择的物品数量
function creteNumSelectUI(callback,itemId,freeNum,goldNum,default,desc,_itemName,_itemNum,minNum,ChangeCb)
    -- 表中物品数据,物品图标
    local itemNum = 0
    local item_data = {}
    if(itemId==nil)then
        --showTip("未提供物品id信息，无法显示数量选择对话框")
        --return
        item_data.name = _itemName
        itemNum = _itemNum
    else
        item_data = ItemUtil.getItemById(itemId) 
        itemNum = ItemUtil.getCacheItemNumBy(itemId) or 0
    end
    if(table.isEmpty(item_data))then
        showTip("获取物品信息失败，无法显示数量选择对话框")
        return
    end
    --local iconSprite = nil
    local freeUseNum = freeNum or 0
    local goldUseNum = goldNum or 0
    local defaultNum = default or 0
    local maxUseNum = itemNum + freeUseNum + goldUseNum
    if(defaultNum>maxUseNum)then
        defaultNum = maxUseNum
    end
    require "script/utils/SlideNumDialog"
    -- 设定初试数值
    function SlideNumDialog:setNum(num)
        local curNum = self.slider:getNum()
        curNum = curNum + num
        if curNum >= self.maxNum then
            self.slider:setNum(self.maxNum)	
            self:_reloadAddBtn()
            self:_reloadNum()
        elseif curNum <= self.minNum then
            self.slider:setNum(self.minNum)	
            self:_reloadReduceBtn()
        else
            self.slider:setNum(curNum)	
            self:_reloadAddBtn()
            self:_reloadReduceBtn()
            self:_reloadNum()
        end
        if self.changeCb ~= nil then
            self.changeCb(curNum)
        end
    end
    local sliderDialog = SlideNumDialog.create(-6400)
    local minNum = minNum or 0
    sliderDialog:setMinNum(minNum)
    sliderDialog:setMaxNum(maxUseNum)
    sliderDialog:setNum(defaultNum-minNum)
    sliderDialog:setTitle("批量使用")
    -- itemNum = ItemUtil.getCacheItemNumBy(itemId) or 0

    sliderDialog:setConfirmCb(function ( pNum )
        if(callback~=nil)then
            callback(pNum)
        end
    end)

        -- UI
    local uiPanel = sliderDialog:getUpUIPanel()
    -- 共可使用%d个
    local totalLael = CCRenderLabel:create("共可使用" .. maxUseNum .. "个\n其中免费"..freeUseNum.."个，".. item_data.name .. itemNum .."个，金币"..goldUseNum.."个", g_sFontName, 24, 1, ccc3(0x49, 0x00, 0x00), type_stroke)
    totalLael:setColor(ccc3(0xff,0xff,0xff))
    totalLael:setAnchorPoint(ccp(0.5,0.5))
    totalLael:setPosition(ccp(uiPanel.size.width*0.5,uiPanel.size.height*0.75))
    uiPanel:addChild(totalLael)
    -- 请选择使用%s的数据
    local textInfo = {
            width = 450, -- 宽度
            alignment = 2, -- 对齐方式  1 左对齐，2 居中， 3右对齐
            lineAlignment = 2,-- 当前行在竖直方向上的对齐方式 1，下对齐， 2，居中， 3，上对齐
            labelDefaultFont = g_sFontName,      -- 默认字体
            labelDefaultSize = 24,          -- 默认字体大小
            labelDefaultColor = ccc3(0xff,0xff,0xff),
            defaultType = "CCRenderLabel",
            defaultRenderType = 1,
            defaultStrokeSize = 1,
            defaultStrokeColor = ccc3(0x49,0x00,0x00),
            elements =
            {	
                {
                    type = "CCRenderLabel", 
                    text = item_data.name,
                    font = g_sFontPangWa,
                    size = 30,
                    color = ccc3(0xfe,0xdb,0x1c)
                },
            }
        }
    local font = GetLocalizeLabelSpriteBy_2("lic_1993", textInfo)
    font:setAnchorPoint(ccp(0.5, 0.5))
    font:setPosition(ccp(uiPanel.size.width*0.5,uiPanel.size.height*0.3))
    uiPanel:addChild(font)

    local downUiPanel = sliderDialog:getDownUIPanel()
    -- 一次最多使用x个
    local descString = desc or " "
    local tipLabel = CCRenderLabel:create(descString, g_sFontName, 24, 1, ccc3(0x49, 0x00, 0x00), type_stroke)
    tipLabel:setColor(ccc3(0xfe, 0xdb, 0x1c))
    tipLabel:setAnchorPoint(ccp(0.5,0.5))
    tipLabel:setPosition(ccp(downUiPanel.size.width*0.5,downUiPanel.size.height*0.8))
    downUiPanel:addChild(tipLabel)
    if(ChangeCb~=nil)then
        sliderDialog:setChangeCb(function ( p )
            ChangeCb(tipLabel,p)
        end)
    end
    sliderDialog:show(10000)
end

--创建悬赏任务界面
function createTaskUI(tipTitle,tipText, buttonFunc, closeCallback)
	if(alertLayer) then
		alertLayer:removeFromParentAndCleanup(true)
		alertLayer = nil
	end
    local function default_func()
        showTip("默认函数")
    end
    tipTitle = tipTitle or "标题"
    if(table.count(tipText)==0)then
        tipText = {{["text"]="正文",["color"]=ccc3(0x78, 0x25, 0x00)}}
    end
    if(table.count(buttonFunc)==0)then
        buttonFunc = {{["text"]="默认按钮",["func"]=default_func}}
    end
    alertLayer = CCLayerColor:create(ccc4(0,0,0,155))
    local function onTouchesHandler( eventType, x, y )
        if (eventType == "began") then
            -- print("began")
    
            return true
        elseif (eventType == "moved") then
            
        else
            -- print("end")
        end
    end
    local function onNodeEvent( event )
        if (event == "enter") then
            -- print("AlertTip.onNodeEvent.......................enter")
            alertLayer:registerScriptTouchHandler(onTouchesHandler, false, -5600, true)
            alertLayer:setTouchEnabled(true)
        elseif (event == "exit") then
            -- print("AlertTip.onNodeEvent.......................exit")
            alertLayer:unregisterScriptTouchHandler()
            alertLayer = nil
        end
    end
	-- layer
	
	alertLayer:registerScriptHandler(onNodeEvent)
	local runningScene = CCDirector:sharedDirector():getRunningScene()
	runningScene:addChild(alertLayer, 9000)
	alertLayer:setTag(345)

	-- 背景
	local fullRect = CCRectMake(0,0,213,171)
	local insetRect = CCRectMake(50,50,113,71)
	local alertBg = CCScale9Sprite:create("images/common/viewbg1.png", fullRect, insetRect)
	alertBg:setPreferredSize(CCSizeMake(600, 800)) -- 背景大小
	alertBg:setAnchorPoint(ccp(0.5, 0.4))
	alertBg:setPosition(ccp(alertLayer:getContentSize().width*0.5, alertLayer:getContentSize().height*0.52))
	alertLayer:addChild(alertBg)
	alertBg:setTag(345)
	alertBg:setScale(g_fScaleX)	

	local alertBgSize = alertBg:getContentSize()

    local function closeAction()
        if(alertLayer) then
            alertLayer:removeFromParentAndCleanup(true)
            alertLayer = nil
        end
        if(closeCallback~=nil)then
            closeCallback()
        end
    end
	-- 关闭按钮bar
	local closeMenuBar = CCMenu:create()
	closeMenuBar:setPosition(ccp(0, 0))
	alertBg:addChild(closeMenuBar)
	closeMenuBar:setTouchPriority(-5601)
	-- 关闭按钮

	local closeBtn = CCMenuItemImage:create("images/common/btn_close_n.png", "images/common/btn_close_h.png")
	closeBtn:registerScriptTapHandler(closeAction)
	closeBtn:setAnchorPoint(ccp(0.5, 0.5))
    closeBtn:setPosition(ccp(alertBg:getContentSize().width*0.95, alertBg:getContentSize().height*0.98))
	closeMenuBar:addChild(closeBtn)
	closeBtn:setVisible(true)

	-- 标题
	local titleLabel = CCRenderLabel:create(tipTitle, g_sFontPangWa, 40, 1, ccc3( 0xff, 0xff, 0xff), type_stroke)
    -- titleLabel:setSourceAndTargetColor(ccc3( 0xff, 0xed, 0x55), ccc3( 0xff, 0x8f, 0x00));
    titleLabel:setColor(ccc3(0x78, 0x25, 0x00))
    titleLabel:setAnchorPoint(ccp(0.5, 0.5))
    titleLabel:setPosition(ccp(alertBgSize.width*0.5, alertBgSize.height*0.9))
    alertBg:addChild(titleLabel)

    -- 按钮层
    local menuBar = CCMenu:create()
	menuBar:setPosition(ccp(0,0))
	menuBar:setTouchPriority(-5601)
	alertBg:addChild(menuBar)

	-- 描述
    for a,b in pairs(tipText) do
        local index = tonumber(a)
        local label_color = b.color or ccc3(0x78, 0x25, 0x00)
        local descLabel = CCLabelTTF:create(b.text, g_sFontName, 28, CCSizeMake(460, 150), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter)
        descLabel:setColor(label_color)
        if(table.count(b.btn)<=0 and b.align~="left")then
            descLabel:setAnchorPoint(ccp(0.5, 0.5))
            descLabel:setPosition(alertBgSize.width * 0.5, alertBgSize.height*(0.95-index*0.12))
        else
            descLabel:setHorizontalAlignment(kCCTextAlignmentLeft)
            descLabel:setAnchorPoint(ccp(0, 0.5))
            descLabel:setPosition(alertBgSize.width * 0.05, alertBgSize.height*(0.95-index*0.12))
            --{["text"]="完成"..n,["func"]=function()choiceTask(tonumber(k),donateTaskByItemId)end,["desc"]=v.procedure.."/"..v.goal,["color"]=HeroPublicLua.getCCColorByStarLevel(v.quality)}
            if(table.count(b.btn)>0)then
                local v = b.btn
                local btn_color = ccc3(0xfe, 0xdb, 0x1c)--ccc3(0x78, 0x25, 0x00)
                local confirmBtn = nil
                if(v.redColor==true)then
                    confirmBtn = LuaCC.create9ScaleMenuItem("images/star/intimate/btn_blue_n.png", "images/star/intimate/btn_blue_h.png",CCSizeMake(120, 70), v.text,ccc3(0xff, 0x00, 0x00),30,g_sFontName,1, ccc3(0x00, 0x00, 0x00))
                else
                    confirmBtn = LuaCC.create9ScaleMenuItem("images/star/intimate/btn_blue_n.png", "images/star/intimate/btn_blue_h.png",CCSizeMake(120, 70), v.text,btn_color,30,g_sFontName,1, ccc3(0x00, 0x00, 0x00))
                end
                confirmBtn:setAnchorPoint(ccp(1, 0.5))
                confirmBtn:setPosition(alertBgSize.width * 0.95, alertBgSize.height*(0.95-index*0.12))
                confirmBtn:registerScriptTapHandler(v.func)
                confirmBtn:setEnabled(true)
                if(v.isDisableBtn==true)then
                    confirmBtn:setEnabled(false)
                end
                menuBar:addChild(confirmBtn, 1, 10001)
                --按钮下方标签
                if(v.desc~=nil)then
                    local item_font = CCRenderLabel:create(v.desc , g_sFontName, 25, 1, ccc3( 0x00, 0x00, 0x00), type_stroke)
                    -- local color = ccc3(0xfe, 0xdb, 0x1c)
                    if(v.redColor==true)then
                        item_font:setColor(ccc3(0xff, 0x00, 0x00))
                    else
                        item_font:setColor(ccc3(0xfe, 0xdb, 0x1c))
                    end
                    -- item_font:setColor(color)
                    item_font:setAnchorPoint(ccp(0.5,0))
                    item_font:setPosition(ccp(confirmBtn:getContentSize().width*0.5,-confirmBtn:getContentSize().height*0.3))
                    confirmBtn:addChild(item_font)
                end
            end
        end
        alertBg:addChild(descLabel)
        descLabel:setTag(345)
    end

	-- 按钮
    local button_num = table.count(buttonFunc)
    local per_line_btn_num = {}
    for k,v in pairs(buttonFunc) do
        local line = v.line or 1
        if(per_line_btn_num[line]==nil)then
            per_line_btn_num[line] = 0
        end
        per_line_btn_num[line] = per_line_btn_num[line] + 1
        buttonFunc[k].index = per_line_btn_num[line]
    end
    require "script/libs/LuaCC"
    for k,v in pairs(buttonFunc)do
        local index = tonumber(k)
        local color = ccc3(0xfe, 0xdb, 0x1c)
        local line = v.line or 1
        local confirmBtn = nil
        --创建按钮
        if(v.redColor==true)then
            confirmBtn = LuaCC.create9ScaleMenuItem("images/star/intimate/btn_blue_n.png", "images/star/intimate/btn_blue_h.png",CCSizeMake(160, 70), v.text,ccc3(0xff, 0x00, 0x00),30,g_sFontName,1, ccc3(0x00, 0x00, 0x00))
        else
            confirmBtn = LuaCC.create9ScaleMenuItem("images/star/intimate/btn_blue_n.png", "images/star/intimate/btn_blue_h.png",CCSizeMake(160, 70), v.text,color,30,g_sFontName,1, ccc3(0x00, 0x00, 0x00))
        end
        confirmBtn:setAnchorPoint(ccp(0.5, 0.5))
        confirmBtn:setPosition(alertBgSize.width/(per_line_btn_num[line]*2)*(v.index*2-1), alertBgSize.height*(0.4-line*0.15))
        confirmBtn:registerScriptTapHandler(v.func)
        confirmBtn:setEnabled(true)
        if(v.isDisableBtn==true)then
            confirmBtn:setEnabled(false)
        end
        menuBar:addChild(confirmBtn, 1, 10001)
        --按钮下方标签
        if(v.desc~=nil)then
            local item_font = CCRenderLabel:create(v.desc , g_sFontName, 25, 1, ccc3( 0x00, 0x00, 0x00), type_stroke)
            -- local color = v.color or ccc3(0xfe, 0xdb, 0x1c)
            if(v.redColor==true)then
                item_font:setColor(ccc3(0xff, 0x00, 0x00))
            else
                item_font:setColor(ccc3(0xfe, 0xdb, 0x1c))
            end
            -- item_font:setColor(color)
            item_font:setAnchorPoint(ccp(0.5,0))
            item_font:setPosition(ccp(confirmBtn:getContentSize().width*0.5,-confirmBtn:getContentSize().height*0.3))
            confirmBtn:addChild(item_font)
        end
    end
end

--shop_name:字符串，商店名字
--db:模块，数据库模块
--db_string:字符串，模块名字去掉前面的DB_
--method:字典，{get=...，buy=...}
--coin_id:数字，使用的货币id
--price_key:字符串，物品价格对应的键
--can_buy_num_key:字符串，物品购买数量对应的键
--buy_item:购买物品id
--buy_num:购买物品数量
function shopBuyItem(shop_name,db,db_string,method,coin_id,price_key,can_buy_num_key,buy_item,buy_num,callbackFunc)
    if(buy_num<=0)then
        if(callbackFunc~=nil)then
            schedule(nil,function()callbackFunc()end,0.2)
        end
        return
    end
    local dbName = db_string
    require ("db/DB_"..dbName)
    local model = db
    local shopName = shop_name
    local goodsList={}
    local shopInfo = {}
    local coin = tonumber(ItemUtil.getItemsDataByStr(coin_id.."|0|0",nil,true)[1].haveNum) or 0
    local coinName = ItemUtil.getItemsDataByStr(coin_id.."|0|0",nil,true)[1].name
    local function getCanBuyNumById( pGoodId )
        local retNum = model.getDataById(pGoodId)[can_buy_num_key]
        if goodsList[tostring(pGoodId)] then
            if(goodsList[tostring(pGoodId)].num)then
                retNum = retNum - tonumber(goodsList[tostring(pGoodId)].num)
            else
                retNum = retNum - tonumber(goodsList[tostring(pGoodId)])
            end
        end
        return retNum
    end
    local function getList( ... )
        local ret = {}
        for k,v in pairs(model[dbName]) do
            local curDBInfo = model.getDataById(v[1])
            if curDBInfo.isSold then
                local tmp = {}
                tmp.id = curDBInfo.id
                tmp.canBuyNum = getCanBuyNumById(tmp.id)
                tmp.dbInfo = curDBInfo
                table.insert(ret,tmp)
            end
        end
        -- 排序id从小到大排序
        -- local sortfun = function ( data1, data2 )
        --     return data1.dbInfo.sortType < data2.dbInfo.sortType
        -- end
        -- table.sort(ret,sortfun)
        return ret
    end
    local function buyGoods( pGoodsId,pNum )
        local requestFunc = function(cbFlag,dictData,bRet)
            printT(dictData)
            if dictData.err == "ok" then
                local name = ItemUtil.getItemById(string.split(model.getDataById(pGoodsId).items,"|")[2]).name
                local num = tonumber(string.split(model.getDataById(pGoodsId).items,"|")[3])
                if(num>1)then
                    showTip(shopName.."购买 "..name.."*"..num.."*"..pNum.." 成功")
                else
                    showTip(shopName.."购买 "..name.."*"..pNum.." 成功")
                end
                local costNum = model.getDataById(pGoodsId)[price_key]
                if(string.find(costNum,"|"))then
                    costNum = string.split(costNum,"|")[3]
                end
                coin = coin - tonumber(costNum)*pNum
                if(callbackFunc~=nil)then
                    schedule(nil,function()callbackFunc(math.max(buy_num-pNum*num,0))end,0.2)
                end
                -- printT(dictData)
            else
                showTip(shopName.."购买出错")
                printT(dictData)
            end
        end
        local args = Network.argsHandlerOfTable({ pGoodsId,pNum })
        Network.no_loading_rpc(requestFunc,method.buy,method.buy,args,true)
    end
    local function getShopInfo( )
        local requestFunc = function(cbFlag,dictData,bRet)
            if dictData.err == "ok" then
                -- printT(dictData)
                goodsList = dictData.ret
                if(dictData.ret.point~=nil)then
                    coin = tonumber(dictData.ret.point)
                end
                printT(goodsList)
                shopInfo = getList()
                -- printT(shopInfo)
                local buy_item_name = ItemUtil.getItemById(buy_item).name
                local want_item={[buy_item_name]=buy_num}
                -- local ret = shopName .. " "
                for k,v in pairs(shopInfo)do
                    -- ret = ret .. ItemUtil.getItemById(string.split(v.dbInfo.items,"|")[2]).name.."*"..v.canBuyNum..","
                    for item,buyNum in pairs(want_item)do
                        if(ItemUtil.getItemById(string.split(v.dbInfo.items,"|")[2]).name == item)then
                            local num = tonumber(string.split(v.dbInfo.items,"|")[3])
                            local need_num = math.ceil(buyNum/num)
                            if(tonumber(v.canBuyNum)>0)then
                                if(need_num<0 or need_num>tonumber(v.canBuyNum))then
                                    need_num = tonumber(v.canBuyNum)
                                    if(callbackFunc==nil)then
                                        showTip("商店剩余购买次数不足")
                                        return
                                    end
                                end
                                local costNum = v.dbInfo[price_key]
                                if(string.find(costNum,"|"))then
                                    costNum = string.split(costNum,"|")[3]
                                end
                                if(coin>tonumber(costNum)*need_num)then
                                    buyGoods(v.id,need_num)
                                else
                                    showTip(coinName.."不足")
                                    return
                                end
                            end
                        end
                    end
                end
                -- prints(ret)
            end
        end
        Network.no_loading_rpc(requestFunc,method.get,method.get,nil,true)
    end
    getShopInfo()
end

--狂欢活动是否开启（不含最后一天兑换的时间）
function isFestivalActOpen()
    require "script/model/utils/ActivityConfigUtil"
    local curTime = TimeUtil.getSvrTimeByOffset()
    local festivalAct = ActivityConfigUtil.getDataByKey("festivalAct").data
    --新区没有狂欢活动时
    if(festivalAct==nil or festivalAct[1]==nil or festivalAct[1].start_time==nil)then
        return false
    end
    local startTime = TimeUtil.getIntervalByTimeDesString(festivalAct[1].start_time)
    local endTime = TimeUtil.getIntervalByTimeDesString(festivalAct[#festivalAct].end_time)
    if(curTime>endTime or curTime<startTime)then
        return false
    end
    return true
end

-- 首页红颜经验领取
function herobeauty_ecvSettleReward()
    showTip("红颜经验")
    if not DataCache.getSwitchNodeState(ksSwitchHeroBeauty, false) then
        showTip("红颜经验，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("红颜游历经验领取成功")
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            require "script/ui/heroBeauty/travel/HeroBeautyTraData"
            local isGet = true
            local info = dictData.ret
            local nowTime = TimeUtil.getSvrTimeByOffset()
            local curInfo = info.beauty or {}
            for k, v in pairs(curInfo) do
                if v.settle_time and tonumber(v.settle_time) ~= 0 then
                    local nowTime = TimeUtil.getSvrTimeByOffset()
                    local time = nowTime - tonumber(v.settle_time)
                    local incomeTime = HeroBeautyTraData.getIncomeTime()
                    if time >= incomeTime then
                        isGet = false
                        break
                    end
                end
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "herobeauty.recvSettleReward", "herobeauty.recvSettleReward", nil, true)
            else
                showTip("红颜经验，请勿重复领取")
                return
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "herobeauty.getInfo", "herobeauty.getInfo", nil, true)
end
-- 领取vip每日奖励
function vipbonus_fetchVipBonus()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("vip每日奖励")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("VIP每日礼包领取成功")
            require "script/ui/vip_benefit/VIPBenefitData"
            VIPBenefitData.writeHave(1)
            finish_table["vipbonus_fetchVipBonus"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local isGet = false
            local info = dictData.ret
            local bonus = tonumber(info.bonus)
            if (bonus == 1) then
                isGet = true
                showTip("vip每日奖励，请勿重复领取")
                finish_table["vipbonus_fetchVipBonus"] = 1
                return
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "vipbonus.fetchVipBonus", "vipbonus.fetchVipBonus", CCArray:create(),
                    true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "vipbonus.getVipBonusInfo", "vipbonus.getVipBonusInfo", nil, true)
end
-- 月签奖励
function sign_gainMonthSignReward()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("月签奖励")
    if not DataCache.getSwitchNodeState(kMonthSignIn, false) then
        showTip("月签，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("月签奖励领取成功")
            finish_table["sign_gainMonthSignReward"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local isGet = false
            local info = dictData.ret
            local signTime = tonumber(info.sign_time)
            local nowTime = TimeUtil.getSvrTimeByOffset()
            if (TimeUtil.isSameDay(signTime, nowTime)) then
                isGet = true
                showTip("月签奖励，请勿重复领取")
                finish_table["sign_gainMonthSignReward"] = 1
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "sign.gainMonthSignReward", "sign.gainMonthSignReward", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "sign.getMonthSignInfo", "sign.getMonthSignInfo", nil, true)
end

-- 积分签到
function dayrecharge_receiveReward()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("积分签到")
    -- if not DataCache.getSwitchNodeState(ksSwitchHeroBeauty,false) then
    --     showTip("红颜经验，等级未达到")
    --     return
    -- end
    require "script/ui/rechargeActive/dayRecharge/DayRechargeDef"
    require "db/DB_Daily_recharge"
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("积分签到奖励领取成功")
            finish_table["dayrecharge_receiveReward"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local getConfData = function(info)
        local confId = tonumber(info.id) or 0
        if confId <= 0 then
            return nil
        end
        return DB_Daily_recharge.getDataById(confId)
    end
    local getConfGoldAndPoint = function(info, pRewardId)
        local gold = 0
        local point = 0
        local confData = getConfData(info)
        if confData ~= nil then
            local strConf = confData["gold_score_" .. pRewardId]
            if strConf ~= nil then
                local arrConf = string.split(strConf, "|")
                gold = tonumber(arrConf[1])
                point = tonumber(arrConf[2])
            end
        end
        return gold, point
    end
    local getLeftTime = function(info)
        local rechargeTime = info.gold_time or 0
        local zeroTime = TimeUtil.getCurDayZeroTime(rechargeTime)
        if zeroTime ~= 0 then
            zeroTime = zeroTime + 7 * 86400
        end
        return zeroTime
    end
    local hasGotReward = function(info, pRewardId)
        local arrReceived = info.received or {}
        for i = 1, #arrReceived do
            if tonumber(pRewardId) == tonumber(arrReceived[i]) then
                return true
            end
        end
        return false
    end
    local getTaskStatus = function(info, pRewardId)
        local status = DayRechargeDef.STATUS_NOT
        local needGold, gainPoint = getConfGoldAndPoint(info, pRewardId)
        local curChargeGold = tonumber(info.recharge_gold) or 0
        local rechargeTime = getLeftTime(info)
        local curTime = TimeUtil.getSvrTimeByOffset()
        local reduceTime = tonumber(rechargeTime) - curTime
        if curChargeGold >= needGold or reduceTime > 0 then
            status = DayRechargeDef.STATUS_CAN_RECEIVE
            local hasGot = hasGotReward(info, pRewardId)
            if hasGot then
                status = DayRechargeDef.STATUS_RECEIVED
            end
        end
        return status
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local isGet = true
            local info = dictData.ret
            local taskNum = tonumber(DB_Daily_recharge.getDataById(1).total_num) or 4
            local recevieTable = {}
            for i = 1, taskNum do
                if (getTaskStatus(info, i) == DayRechargeDef.STATUS_CAN_RECEIVE) then
                    table.insert(recevieTable, i)
                    isGet = false
                end
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable(recevieTable) -- 领取奖励列表{1,2,3,4}
                Network.no_loading_rpc(callback, "dayrecharge.receiveReward", "dayrecharge.receiveReward", args, true)
            else
                showTip("积分签到，请勿重复领取")
                finish_table["dayrecharge_receiveReward"] = 1
                return
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "dayrecharge.getInfo", "dayrecharge.getInfo", nil, true)
end

-- 跨服排位段位奖励
function worldrank_recvDailyReward()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("跨服排位段位奖励")
	require "db/DB_Kuafu_ranking"
	local rankData = DB_Kuafu_ranking.getDataById(1)
	local needLevel = tonumber(rankData.level)
	-- 2.玩家等级是否符合
	if (UserModel.getHeroLevel() < needLevel) then
		showTip("跨服排位，等级未达到")
		return
	end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("跨服排位段位奖励领取成功")
            finish_table["worldrank_recvDailyReward"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local isGet = false
            local info = dictData.ret
            local curServerTime = BTUtil:getSvrTimeInterval()
            local can_reward_time = tonumber(info.time_conf.reward_time)
            local info_callback = function(cbFlag, dictData, bRet)
                if dictData.err == "ok" then
                    local info = dictData.ret
                    local serverTime = tonumber(TimeUtil.getSvrTimeByOffset())
                    local zeroTime = tonumber(TimeUtil.getCurDayZeroTime(serverTime))
                    local rewardTime = tonumber(info.reward_time)
                    if (rewardTime >= zeroTime and rewardTime <= (zeroTime + 24 * 60 * 60)) then
                        isGet = true
                        showTip("跨服排位段位奖励，请勿重复领取")
                        finish_table["worldrank_recvDailyReward"] = 1
                        return
                    end
                    if (not isGet) then
                        Network.no_loading_rpc(callback, "worldrank.recvDailyReward", "worldrank.recvDailyReward", nil,true)
                    end
                end
            end
            if (curServerTime > can_reward_time) then
                Network.no_loading_rpc(info_callback, "worldrank.getInfo", "worldrank.getInfo", nil, true)
            else
                showTip("跨服排位段位奖励，当前时段无法领取")
                if(TimeUtil.getDifferDay(can_reward_time)~=0)then
                    finish_table["worldrank_recvDailyReward"] = 1
                end
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "worldrank.getConf", "worldrank.getConf", nil, true)
end

-- 国战领奖
function countrywarinner_worship()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("国战膜拜")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("国战膜拜奖励领取成功")
            finish_table["countrywarinner_worship"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            require "script/ui/countryWar/CountryWarMainData"
            require "script/ui/countryWar/CountryWarDef"
            CountryWarMainData.setCountryWarInfo(dictData.ret)
            local isGet = false
            local curStage = CountryWarMainData.getCurStage()
            local worshipStage = CountryWarDef.WORSHIP
            if curStage ~= worshipStage then
                isGet = true
                showTip("国战膜拜，当前非膜拜时间")
                return
            end
            -- 是否可以膜拜
            local worshipTime = tonumber(dictData.ret.detail.worship_time)
            local curTIme = TimeUtil.getSvrTimeByOffset(0)
            if TimeUtil.isSameDay(worshipTime, curTIme) then
                -- 不可膜拜
                isGet = true
                showTip("国战膜拜，请勿重复领取")
                finish_table["countrywarinner_worship"] = 1
                return
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "countrywarinner.worship", "countrywarinner.worship", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "countrywarinner.getCoutrywarInfo", "countrywarinner.getCoutrywarInfo", nil,true)
end
-- 逐鹿中原膜拜，参数1表示第一个银币膜拜
function throne_worship()
    showTip("逐鹿中原膜拜")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("逐鹿中原膜拜奖励领取成功")
            finish_table["throne_worship"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local info_callback = function(cbFlag, dictData, bRet)
                if dictData.err == "ok" then
                    local isGet = false
                    local info = dictData.ret
                    local worship_time = tonumber(info.worship_time)
                    if (tonumber(worship_time) ~= 0 and TimeUtil.getDifferDay(worship_time) == 0) then
                        isGet = true
                        showTip("逐鹿中原膜拜，请勿重复领取")
                        finish_table["throne_worship"] = 1
                        return
                    end
                    local setValue =  tonumber(default_value["throne_worship"]) or 1
                    if(setValue>3 or setValue<1)then
                        setValue = 1
                    end
                    if (not isGet) then
                        local arg = CCArray:create()
                        arg:addObject(CCInteger:create(setValue)) -- 取值1~3分别对应三种等级的膜拜
                        Network.no_loading_rpc(callback, "throne.worship", "throne.worship", arg, true)
                    end
                end
            end
            curTime = TimeUtil.getSvrTimeByOffset()
            if (not table.isEmpty(dictData.ret.time_conf) and curTime >= tonumber(dictData.ret.time_conf.reward_end_time) and curTime <=
                tonumber(dictData.ret.time_conf.end_time)) then
                Network.no_loading_rpc(info_callback, "throne.getWorshipInfo", "throne.getWorshipInfo", nil, true)
            else
                showTip("逐鹿中原膜拜，当前非膜拜时间")
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "throne.getConf", "throne.getConf", nil, true)
end
-- 争霸天下膜拜
function guildpoint_worship()
    showTip("争霸天下膜拜")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("争霸天下膜拜奖励领取成功")
            finish_table["guildpoint_worship"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local info = dictData.ret
            local round = tonumber(info.round)
            local status = tonumber(info.status)
            local sub_round = tonumber(info.sub_round)
            local worship_time = tonumber(info.worship_time)
            require "script/ui/guildpoint/GuildPointDef"
            if round ~= GuildPointDef.ROUND_2TO1 or sub_round ~= 3 or status ~= GuildPointDef.STATUS_DONE then
                showTip("当前不在争霸天下膜拜时间段")
                return
            end
            local info_callback = function()
                if (dictData.err == "ok") then
                    local isGet = false
                    local lastTime = dictData.ret.worship_time or worship_time
                    if not lastTime then
                        isGet = true
                    end
                    if lastTime == 0 then
                        isGet = false
                    end
                    local diffDay = TimeUtil.getDifferDay(lastTime)
                    if diffDay == 0 then
                        isGet = true
                        showTip("争霸天下已膜拜，请勿重复膜拜")
                        finish_table["guildpoint_worship"] = 1
                        return
                    else
                        isGet = false
                    end
                    if (not isGet) then
                        local worship = function()
                            Network.no_loading_rpc(callback, "guildpoint.worship", "guildpoint.worship", nil, true)
                        end
                        schedule(CCDirector:sharedDirector():getRunningScene(), worship, 0.1)
                    end
                end
            end
            local getWorshipInfo = function()
                Network.no_loading_rpc(info_callback, "guildpoint.getWorshipInfo", "guildpoint.getWorshipInfo", nil,true)
            end
            schedule(CCDirector:sharedDirector():getRunningScene(), getWorshipInfo, 0.1)
        end
    end
    Network.no_loading_rpc(requestFunc, "guildpoint.getInfo", "guildpoint.getInfo", nil, true)
end

-- 三国激斗膜拜
function worldteam_worship()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("三国激斗膜拜")
    if(UserModel.getHeroLevel()<(tonumber(ActivityConfigUtil.getDataByKey("worldteam").data[1].level) or 112))then
        showTip("三国激斗，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("三国激斗膜拜奖励领取成功")
            finish_table["worldteam_worship"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local round = tonumber(info.round)
            local status = tonumber(info.status)
            require "script/ui/WorldTeam/WorldTeamDef"
            if round ~= WorldTeamDef.ROUND_2TO1 or status ~= WorldTeamDef.STATUS_DONE then
                isGet = true
                showTip("当前不在三国激斗膜拜时间段")
                return
            end
            local lastTime = info.worship_time
            if lastTime == 0 then
                isGet = false
            end
            local diffDay = TimeUtil.getDifferDay(lastTime)
            if diffDay == 0 then
                isGet = true
                showTip("三国激斗已膜拜，请勿重复膜拜")
                finish_table["worldteam_worship"] = 1
                return
            else
                isGet = false
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "worldteam.worship", "worldteam.worship", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "worldteam.getInfo", "worldteam.getInfo", nil, true)
end
-- 跨服比武膜拜
function worldcompete_worship()
    showTip("跨服比武膜拜")
    if not DataCache.getSwitchNodeState(ksSwitchKFBW, false) then
        showTip("跨服比武，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("跨服比武膜拜奖励领取成功")
            schedule(CCDirector:sharedDirector():getRunningScene(), worldcompete_worship, 0.5)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            -- 根据配置时间来调用比武还是膜拜
            local curTime = TimeUtil.getSvrTimeByOffset()
            local battleStartTime = tonumber(info.begin_time)         -- 比武开启时间
            local battleEndTime = tonumber(info.end_time)            -- 比武结束时间  也是膜拜开始时间
            local prostrateEndTime = tonumber(info.reward_end_time)    -- 膜拜结束时间
            local newBattleStartTime = tonumber(info.period_end_time)   -- 整个活动结束时间  即新活动开启时间
            if battleStartTime <= curTime and curTime < battleEndTime then
                -- 比武
                isGet = true
                showTip("当前非跨服比武膜拜时间")
                local diffDay = TimeUtil.getDifferDay(battleEndTime)
                --比武最后一天晚上可以领奖，其他时间整天都不可以，可以直接标记已领取
                if(diffDay ~= 0)then
                    finish_table["worldcompete_worship"] = 1
                end
                return
            elseif battleEndTime <= curTime and curTime < prostrateEndTime then
                -- 膜拜
                isGet = false
            elseif prostrateEndTime <= curTime and curTime < newBattleStartTime then
                -- 等待下届活动开启
                isGet = true
                showTip("当前非跨服比武膜拜时间")
                finish_table["worldcompete_worship"] = 1
                return
            end
            local worship_num = tonumber(info.worship_num)
            local userLevel = UserModel.getHeroLevel()
            require "db/DB_Kuafu_contest"
            local showSecCondition = tonumber(DB_Kuafu_contest.getDataById(1).show_level)
            if userLevel < showSecCondition then
                if(worship_num==1)then
                    isGet = true
                    showTip("跨服比武当前等级仅可膜拜一次，请勿重复膜拜")
                    finish_table["worldcompete_worship"] = 1
                    return
                end
            else
                if worship_num == 2 then
                    isGet = true
                    showTip("跨服比武已膜拜，请勿重复膜拜")
                    finish_table["worldcompete_worship"] = 1
                    return
                end
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "worldcompete.worship", "worldcompete.worship", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "worldcompete.getWorldCompeteInfo", "worldcompete.getWorldCompeteInfo", nil, true)
end

-- 悬赏榜领奖
function mission_receiveDayReward()
    showTip("悬赏榜领奖")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("悬赏榜奖励领取成功")
            finish_table["mission_receiveDayReward"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            require "script/ui/mission/MissionMainData"
            -- 1.判断当前是否在领奖时间段内
            local nowTime = TimeUtil.getSvrTimeByOffset()
            local donateTime = MissionMainData.getStartTime() + MissionMainData.getDonateTime()
            if nowTime < donateTime + MissionMainData.getRankSpendTime() and nowTime > MissionMainData.getStartTime() then
                -- 当前时间小于排名结束时间
                isGet = true
                showTip("悬赏榜奖励，排名结束才可以领取奖励")
                return
            end
            -- 2.下届活动开始前两分钟不能领取
            if nowTime < MissionMainData.getStartTime() and MissionMainData.getConfigSeason() > 0 then
                if nowTime > MissionMainData.getStartTime() - MissionMainData.getRankSpendTime() then
                    isGet = true
                    showTip("悬赏榜奖励，新的悬赏活动正在努力开启中，不能领奖")
                    return
                end
            end
            -- 3.今天是否已经领过奖励
            local reciveTime = info.dayreward_time
            if TimeUtil.isSameDay(reciveTime, nowTime) then
                isGet = true
                showTip("悬赏榜奖励，请勿重复领取")
                finish_table["mission_receiveDayReward"] = 1
                return
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "mission.receiveDayReward", "mission.receiveDayReward", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "mission.getMissionInfo", "mission.getMissionInfo", nil, true)
end
-- 七星台抽卡
function sevenslottery_lottery(set_num,is_use_gold,callbackFunc)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    set_num = set_num or 0
    showTip("七星台免费抽卡")
    if not DataCache.getSwitchNodeState(ksSwitchSevenLottery, false) then
        showTip("七星台，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("七星台免费抽卡成功")
            finish_table["sevenslottery_lottery"] = 1
            if(callbackFunc~=nil)then
                callbackFunc(true)
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local num = tonumber(default_value["sevenslottery_lottery"]) or 1
            if(set_num>0)then
                num = set_num
            end
            local free = tonumber(info.free)
            -- prints("info.free "..info.free)
            if (free == 0 and set_num <=0) then
                isGet = true
                showTip("七星台已抽卡，请勿重复抽取")
                finish_table["sevenslottery_lottery"] = 1
                return
            end
            require "db/DB_Sevenstar_altar"
            local dbData = DB_Sevenstar_altar.getDataById(info.curr_id)
            local itemData = string.split(dbData.cost_item, "|")
            local itemNum = ItemUtil.getCacheItemNumBy(itemData[2])
            if (itemNum < num - free) then
                isGet = true
                showTip("缺少七星令")
                if(default_value["sevenslottery_lottery_gold"] == 1 or is_use_gold)then
                    showTip("七星台使用金币抽卡")
                    isGet = false
                elseif(default_value["sevenslottery_lottery_gold"] == 0)then
                    return
                else
                    return
                end
            end
            if (not isGet) then
                local args = CCArray:create()
                args:addObject(CCInteger:create(3)) -- 抽卡类别，固定是3
                args:addObject(CCInteger:create(num)) -- 抽卡数量
                Network.no_loading_rpc(callback, "sevenslottery.lottery", "sevenslottery.lottery", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "sevenslottery.getSevensLotteryInfo", "sevenslottery.getSevensLotteryInfo", nil,true)
end
-- 神器台抽卡
function godbless_bless(set_num,is_use_gold,callbackFunc)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    set_num = set_num or 0
    showTip("神器台免费抽卡")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("神器台免费抽卡成功")
            finish_table["godbless_bless"] = 1
            if(callbackFunc~=nil)then
                callbackFunc(true)
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local num = tonumber(default_value["godbless_bless"]) or 1
            if(set_num>0)then
                num = set_num
            end
            local info = dictData.ret
            local free = tonumber(info.free)
            if (free == 0 and set_num<=0) then
                isGet = true
                showTip("神器台已抽卡，请勿重复抽取")
                finish_table["godbless_bless"] = 1
                return
            end
            require "script/ui/artifact/pray/ArtifactPrayData"
            local itemNum = ArtifactPrayData.getRemainItemTime()
            if (itemNum < num - free) then
                isGet = true
                showTip("缺少祈福令")
                if(default_value["godbless_bless_gold"] == 1 or is_use_gold)then
                    showTip("神器台使用金币抽卡")
                    isGet = false
                elseif(default_value["godbless_bless_gold"] == 0)then
                    return
                else
                    return
                end
            end
            if (not isGet) then
                local args = CCArray:create()
                args:addObject(CCInteger:create(num)) -- 抽卡次数
                Network.no_loading_rpc(callback, "godbless.bless", "godbless.bless", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "godbless.getInfo", "godbless.getInfo", nil, true)
end
-- 普通名将抽卡
function forfmhero_draw(set_num,is_use_gold,callbackFunc)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    set_num = set_num or 0
    showTip("普通名将抽卡")
    if not DataCache.getSwitchNodeState(ksSwitchRelpHero, false) then
        showTip("普通名将，等级未达到")
        return
    end
    require "db/DB_Replacehero_platform_aj"
    local endtime = DB_Replacehero_platform_aj.getDataById(1).time
    if (TimeUtil.getSvrTimeByOffset() > TimeUtil.getCurDayZeroTime() + endtime) then
        showTip("当前不在普通名将抽卡时间")
        finish_table["forfmhero_draw"] = 1
        if(callbackFunc~=nil)then
            callbackFunc(false)
        end
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("普通名将抽卡成功")
            finish_table["forfmhero_draw"] = 1
            if(callbackFunc~=nil)then
                callbackFunc(true)
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local num = tonumber(default_value["forfmhero_draw"]) or 2
            if(set_num>0)then
                num = set_num
            end
            local used_free_num = tonumber(info.free_num)
            if (used_free_num ~= 0 and set_num<=0) then
                isGet = true
                showTip("普通名将已抽卡，请勿重复抽卡")
                finish_table["forfmhero_draw"] = 1
                return
            end
            require "script/ui/herorepl/platform/HeroReplPlfData"
            local item_num = HeroReplPlfData.haveCostItemNum()
            if (item_num < num - used_free_num) then
                isGet = true
                showTip("缺少名将令")
                if(default_value["forfmhero_draw_gold"] == 1 or is_use_gold)then
                    showTip("普通名将台使用金币抽卡")
                    isGet = false
                elseif(default_value["forfmhero_draw_gold"] == 0)then
                    return
                else
                    return
                end
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({num}) -- 抽卡次数
                Network.no_loading_rpc(callback, "forfmhero.draw", "forfmhero.draw", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "forfmhero.getInfo", "forfmhero.getInfo", nil, true)
end
-- 高级名将抽卡
function forfmherobt_draw(set_num,is_use_gold,callbackFunc)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    set_num = set_num or 0
    showTip("高级名将抽卡")
    if not DataCache.getSwitchNodeState(ksSwitchRelpHero, false) then
        showTip("高级名将，等级未达到")
        return
    end
    require "db/DB_Replacehero_platform_aj"
    local endtime = DB_Replacehero_platform_aj.getDataById(1).time
    if (TimeUtil.getSvrTimeByOffset() > TimeUtil.getCurDayZeroTime() + endtime) then
        showTip("当前不在高级名将抽卡时间")
        finish_table["forfmherobt_draw"] = 1
        if(callbackFunc~=nil)then
            callbackFunc(false)
        end
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("高级名将抽卡成功")
            finish_table["forfmherobt_draw"] = 1
            if(callbackFunc~=nil)then
                callbackFunc(true)
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local num = tonumber(default_value["forfmherobt_draw"]) or 2
            if(set_num>0)then
                num = set_num
            end
            local used_free_num = tonumber(info.free_num)
            if (used_free_num ~= 0 and set_num<=0) then
                isGet = true
                showTip("高级名将已抽卡，请勿重复抽卡")
                finish_table["forfmherobt_draw"] = 1
                return
            end
            require "script/ui/herorepl/darkplatform/HeroDarkPlfData"
            local item_num = HeroDarkPlfData.haveCostItemNum()
            if (item_num < num - used_free_num) then
                isGet = true
                showTip("缺少高级名将令")
                if(default_value["forfmherobt_draw_gold"] == 1 or is_use_gold)then
                    showTip("高级名将台使用金币抽卡")
                    isGet = false
                elseif(default_value["forfmherobt_draw_gold"] == 0)then
                    return
                else
                    return
                end
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({num}) -- 抽卡次数
                Network.no_loading_rpc(callback, "forfmherobt.draw", "forfmherobt.draw", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "forfmherobt.getInfo", "forfmherobt.getInfo", nil, true)
end
-- 后军台抽卡
function houjunfactory_lottery(set_num,is_use_gold,callbackFunc)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    set_num = set_num or 0
    showTip("后军台抽卡")
    require "db/DB_Houjun_altar"
    if not DataCache.getSwitchNodeState(ksHouJun, false) then
        showTip("后军台，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("后军台抽卡成功")
            finish_table["houjunfactory_lottery"] = 1
            if(callbackFunc~=nil)then
                callbackFunc(true)
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local ReArmyData_getCostArray = function(pLotteryNum, pUseItem, _info)
        local num = tonumber(pLotteryNum) or 0
        local useItem = pUseItem or false
        local ret = {}
        ret.free = 0 -- 使用免费的次数
        ret.gold = 0 -- 使用金币次数
        ret.item = 0 -- 使用道具次数
        local err = 0
        -- 免费判断
        if tonumber(_info.free) > 0 then
            ret.free = math.min(num, _info.free)
            num = num - ret.free
        else
            -- Logger.debug("\n\n\t无免费次数\n")
        end
        function canLotteryByItem()
            require "db/DB_Houjun_altar"
            local itemArr = string.split(DB_Houjun_altar.getDataById(1).cost_coin, "|")
            local itemId = tonumber(itemArr[2])
            local perNum = tonumber(itemArr[3]) -- 使用道具抽一次花费的道具数量
            local curNum = ItemUtil.getCacheItemNumBy(itemId)

            return curNum >= perNum, curNum, perNum
        end
        -- 使用道具判断
        if num > 0 and useItem then
            local can, curNum, perNum = canLotteryByItem()
            if can then
                ret.item = math.min(num, math.floor(curNum / perNum))
                num = num - ret.item
                err = 0
            else
                -- Logger.debug("\n\n\t道具不足\n")
            end
        end
        function getTodayGoldNum(_info)
            local num = tonumber(_info.num)
            local max = tonumber(DB_Houjun_altar.getDataById(1).times_limit)
            return num, max
        end
        -- 花费金币判断（每日次数有限）
        local historyNum, max = getTodayGoldNum(_info)
        if num > 0 and historyNum < max then
            -- 有剩余次数，检查金币是否充足
            local curGold = UserModel.getGoldNumber()
            local perGold = tonumber(DB_Houjun_altar.getDataById(1).cost_gold)
            if curGold >= perGold then
                ret.gold = math.min(num, max - historyNum, math.floor(curGold / perGold))
                err = 0
            elseif ret.free == 0 and ret.item == 0 then
                err = 2 -- 金币不足
            end
        elseif ret.free == 0 and ret.item == 0 then
            err = 1 -- 次数不足
        end
        return ret, err
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local num = tonumber(default_value["houjunfactory_lottery"]) or 1 -- 抽卡次数
            if(set_num>0)then
                num = set_num
            end
            local lotteryNum = 0
            local info = dictData.ret
            -- prints("后军info.free"..info.free)
            -- 如果没有免费次数就不抽了
            if (tonumber(info.free) == 0 and set_num<=0) then
                isGet = true
                showTip("后军台已抽卡，请勿重复抽取")
                finish_table["houjunfactory_lottery"] = 1
                return
            end
            local costArray, err = ReArmyData_getCostArray(num, true, info)
            for k, v in pairs(costArray) do
                lotteryNum = lotteryNum + v
            end
            if (costArray.gold ~= 0) then
                isGet = true
                showTip("缺少后军令")
                if(default_value["houjunfactory_lottery_gold"] == 1 or is_use_gold)then
                    showTip("后军台使用金币抽卡")
                    isGet = false
                elseif(default_value["houjunfactory_lottery_gold"] == 0)then
                    return
                else
                    return
                end
            end
            -- 无法抽取
            if lotteryNum == 0 then
                isGet = true
                if err == 1 then
                    showTip("后军台抽卡未持有道具且今日剩余次数不足")
                elseif err == 2 then
                    showTip("后军台抽卡金币不足")
                end
                return
            end
            if (not isGet) then
                showTip("后军台抽卡" .. num .. "次")
                local args = CCArray:create()
                local dict = CCDictionary:create()
                dict:setObject(CCInteger:create(costArray.free), tostring(0)) -- 使用免费次数
                dict:setObject(CCInteger:create(costArray.item), tostring(1)) -- 使用道具次数
                dict:setObject(CCInteger:create(costArray.gold), tostring(2)) -- 使用金币次数
                args:addObject(dict)
                Network.no_loading_rpc(callback, "houjunfactory.lottery", "houjunfactory.lottery", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "houjunfactory.getInfo", "houjunfactory.getInfo", nil, true)
end
-- 铜雀台抽卡
function tongque_lottery(set_num,is_use_gold,callbackFunc)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    set_num = set_num or 0
    showTip("铜雀台抽卡")
    require "db/DB_Stage_tongque"
    if not DataCache.getSwitchNodeState(ksSwitchBeautyLottery, false) then
        showTip("铜雀台，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("铜雀台抽卡成功")
            finish_table["tongque_lottery"] = 1
            if(callbackFunc~=nil)then
                callbackFunc(true)
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local BeautyLotteryData_getCostArray = function(pLotteryNum, pUseItem, _info)
        local num = tonumber(pLotteryNum) or 0
        local useItem = pUseItem or false
        local ret = {}
        ret.free = 0 -- 使用免费的次数
        ret.gold = 0 -- 使用金币次数
        ret.item = 0 -- 使用道具次数
        local err = 0
        -- 免费判断
        if tonumber(_info.free) > 0 then
            ret.free = math.min(num, _info.free)
            num = num - ret.free
        else
            -- Logger.debug("\n\n\t无免费次数\n")
        end
        function canLotteryByItem()
            require "db/DB_Stage_tongque"
            local itemArr = string.split(DB_Stage_tongque.getDataById(_info.curr_id).cost_item, "|")
            local itemId = tonumber(itemArr[2])
            local perNum = tonumber(itemArr[3]) -- 使用道具抽一次花费的道具数量
            local curNum = ItemUtil.getCacheItemNumBy(itemId)

            return curNum >= perNum, curNum, perNum
        end
        -- 使用道具判断
        if num > 0 and useItem then
            local can, curNum, perNum = canLotteryByItem()
            if can then
                ret.item = math.min(num, math.floor(curNum / perNum))
                num = num - ret.item
                err = 0
            else
                -- Logger.debug("\n\n\t道具不足\n")
            end
        end
        function getTodayGoldNum(_info)
            local num = tonumber(_info.num)
            
            local max = tonumber(DB_Stage_tongque.getDataById(_info.curr_id).daily_times)
            return num, max
        end
        -- 花费金币判断（每日次数有限）
        local historyNum, max = getTodayGoldNum(_info)
        if num > 0 and historyNum < max then
            -- 有剩余次数，检查金币是否充足
            local curGold = UserModel.getGoldNumber()
            local perGold = DB_Stage_tongque.getDataById(tonumber(_info.curr_id)).cost_once
            if curGold >= perGold then
                ret.gold = math.min(num, max - historyNum, math.floor(curGold / perGold))
                err = 0
            elseif ret.free == 0 and ret.item == 0 then
                err = 2 -- 金币不足
            end
        elseif ret.free == 0 and ret.item == 0 then
            err = 1 -- 次数不足
        end
        return ret, err
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local num = tonumber(default_value["tongque_lottery"]) or 2 -- 抽卡次数
            if(set_num>0)then
                num = set_num
            end
            local lotteryNum = 0
            local info = dictData.ret
            -- prints("铜雀info.free"..info.free)
            -- 如果没有免费次数就不抽了
            if (tonumber(info.free) == 0 and set_num<=0) then
                isGet = true
                showTip("铜雀台已抽卡，请勿重复抽取")
                finish_table["tongque_lottery"] = 1
                return
            end
            local costArray, err = BeautyLotteryData_getCostArray(num, true, info)
            for k, v in pairs(costArray) do
                lotteryNum = lotteryNum + v
            end
            if (costArray.gold ~= 0) then
                isGet = true
                showTip("缺少红颜令")
                if(default_value["tongque_lottery_gold"] == 1 or is_use_gold)then
                    showTip("铜雀台使用金币抽卡")
                    isGet = false
                elseif(default_value["tongque_lottery_gold"] == 0)then
                    return
                else
                    return
                end
            end
            -- 无法抽取
            if lotteryNum == 0 then
                isGet = true
                if err == 1 then
                    showTip("铜雀台抽卡未持有道具且今日剩余次数不足")
                elseif err == 2 then
                    showTip("铜雀台抽卡金币不足")
                end
                return
            end
            if (not isGet) then
                showTip("铜雀台抽卡" .. num .. "次")
                local args = CCArray:create()
                local dict = CCDictionary:create()
                dict:setObject(CCInteger:create(costArray.free), tostring(0)) -- 使用免费次数
                dict:setObject(CCInteger:create(costArray.item), tostring(1)) -- 使用道具次数
                dict:setObject(CCInteger:create(costArray.gold), tostring(2)) -- 使用金币次数
                args:addObject(dict)
                Network.no_loading_rpc(callback, "tongque.lottery", "tongque.lottery", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "tongque.getInfo", "tongque.getInfo", nil, true)
end

-- 军团银币贡献
function guild_contribute()
    showTip("军团贡献")
    if not DataCache.getSwitchNodeState(ksSwitchGuild, false) then
        showTip("军团，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("军团贡献成功")
            finish_table["guild_contribute"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local GuildMemberInfo = dictData.ret
            local isGet = false
            if (tonumber(GuildMemberInfo.contri_num) <= 0) then
                isGet = true
                showTip("军团贡献，请勿重复贡献")
                finish_table["guild_contribute"] = 1
                return
            end
            local setValue =  tonumber(default_value["guild_contribute"]) or 1
            if(setValue>5 or setValue<1)then
                setValue = 1
            end
            if (not isGet) then
                local arg = CCArray:create()
                arg:addObject(CCInteger:create(setValue)) -- 军团建设类型 1（初级建设）-5（究极建设）
                Network.no_loading_rpc(callback, "guild.contribute", "guild.contribute", arg, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "guild.getMemberInfo", "guild.getMemberInfo", nil, true)
end
-- 粮草采集
function guild_quickHarvest()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("粮草采集")
    if not DataCache.getSwitchNodeState(ksSwitchGuild, false) then
        showTip("军团，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("粮草采集成功")
            finish_table["guild_quickHarvest"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local GuildMemberInfo = dictData.ret
            local isGet = false
            local liangtian = GuildMemberInfo.va_member.fields
            local num = 0
            for k, v in pairs(liangtian) do
                -- prints("liangtian "..table.concat(v," "))
                if (tonumber(v[1]) > 0) then
                    num = num + 1
                end
            end
            if (num == 0) then
                isGet = true
                showTip("粮草采集，请勿重复采集")
                finish_table["guild_quickHarvest"] = 1
                return
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "guild.quickHarvest", "guild.quickHarvest", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "guild.getMemberInfo", "guild.getMemberInfo", nil, true)
end

-- 攻城boss购买次数
function guildcopy_buyBoss()
    local buy_num = 0
    local num = default_value["guildcopy_buyBoss"] or 0
    require "db/DB_GroupCopy_rule"
    local costData = DB_GroupCopy_rule.getDataById(1)
    local costArray = string.split(costData.price,",")
    local function buyBossTime()
        -- body
        local buyTimeFunc = function ( cbFlag, dictData, bRet )
            if (dictData.err == "ok") then
                local goldNum = 0
                for curBuyNum=1,#costArray do
                    local costNumArray = string.split(costArray[curBuyNum],"|")
                    if(curBuyNum>buy_num and curBuyNum<num)then
                        goldNum = goldNum + tonumber(costNumArray[2])
                    end
                end
                UserModel.addGoldNumber(-goldNum)
                -- GuildBossCopyData.setBuyTime()
                showTip("购买攻城BOSS "..num-buy_num.."次成功")
                finish_table["guildcopy_buyBoss"] = 1
            else
                showTip("购买攻城BOSS失败")
            end
        end
        local args = Network.argsHandler(num-buy_num)--购买的次数
        Network.no_loading_rpc(buyTimeFunc,"guildcopy.buyBoss", "guildcopy.buyBoss", args ,true)
    end

    local function guildcopy_getUserInfo()
        local requestFunc = function(cbFlag, dictData, bRet)
            if (dictData.err == "ok") then
                local info = dictData.ret
                local canBuyNum = #costArray
                -- info.boss_info.buy_boss_num是购买的攻打次数
                buy_num = tonumber(info.boss_info.buy_boss_num)
                -- showTip(canBuyNum)
                if(buy_num > canBuyNum)then
                    buy_num = canBuyNum
                end
                if (buy_num >= num) then
                    showTip("攻城boss购买次数，请勿重复购买")
                    finish_table["guildcopy_buyBoss"] = 1
                    return
                end
                buyBossTime()
            end
        end
        Network.no_loading_rpc(requestFunc, "guildcopy.getUserInfo", "guildcopy.getUserInfo", nil, true)
    end
    guildcopy_getUserInfo()
end

-- 攻城boss
function guildcopy_attackBoss()
    showTip("攻城boss")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("攻城boss攻打成功")
            schedule(CCDirector:sharedDirector():getRunningScene(), guildcopy_attackBoss, 1)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            -- 每天固定三次免费攻打攻城boss，info.boss_info.atk_boss_num是已经攻打的次数，info.boss_info.buy_boss_num是购买的攻打次数
            local atk_boss_num = 3 - tonumber(info.boss_info.atk_boss_num) + tonumber(info.boss_info.buy_boss_num)
            if (atk_boss_num == 0) then
                isGet = true
                showTip("攻城boss，请勿重复攻打")
                finish_table["guildcopy_attackBoss"] = 1
                return
            end
            local cd = tonumber(info.boss_info.cd)
            local curtime = TimeUtil.getSvrTimeByOffset()
            local time = 0
            if (cd > curtime) then
                time = cd - curtime
                isGet = true
                showTip("攻城boss，已被击杀，" .. time .. "秒后重生")
                schedule(CCDirector:sharedDirector():getRunningScene(), guildcopy_attackBoss, time + 1)
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "guildcopy.attackBoss", "guildcopy.attackBoss", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "guildcopy.getUserInfo", "guildcopy.getUserInfo", nil, true)
end
-- 关公殿免费参拜
function guild_reward_free()
    showTip("关公殿免费参拜")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            require "script/model/user/UserModel"
    		local nowLevel = dictData.ret.level
            require "db/DB_Legion_feast"
    		local guanGongInfo = DB_Legion_feast.getDataById(1)
    		local growTili = math.floor(guanGongInfo.baseExecution+guanGongInfo.growExecution*nowLevel/100)
    		UserModel.addEnergyValue(growTili)

    		local growNaili = math.floor(guanGongInfo.baseStamina+guanGongInfo.growStamina*nowLevel/100)
    		UserModel.addStaminaNumber(growNaili)

    		local itemNumP = math.floor(guanGongInfo.basePrestige+guanGongInfo.growPrestige*nowLevel/100)
    	    UserModel.addPrestigeNum(tonumber(itemNumP))

    	    local itemNumS = math.floor(guanGongInfo.baseSoul+guanGongInfo.growSoul*nowLevel/100)
    	    UserModel.addSoulNum(tonumber(itemNumS))

    	    local itemNumSi = math.floor(guanGongInfo.baseSilver+guanGongInfo.growSilver*nowLevel/100)
    	    UserModel.addSilverNumber(tonumber(itemNumSi))

    	    local itemNumG = math.floor(guanGongInfo.baseGold+guanGongInfo.growGold*nowLevel/100)
    	    UserModel.addGoldNumber(tonumber(itemNumG))
            showTip("关公殿免费参拜成功，体力+ ".. growTili)
            finish_table["guild_reward_free"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    require "db/DB_Legion_feast"
    if (TimeUtil.getSvrTimeByOffset() < TimeUtil.getIntervalByTime(tonumber(DB_Legion_feast.getDataById(1).beginTime))) then
        showTip("当前不在关公殿免费参拜时间")
        return
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local reward_num = tonumber(info.reward_num)
            if (reward_num == 0) then
                isGet = true
                showTip("关公殿免费参拜，请勿重复参拜")
                finish_table["guild_reward_free"] = 1
                return
            end
            if (not isGet) then
                local subArg = CCArray:create()
                subArg:addObject(CCInteger:create(0)) -- 免费参拜固定是0，金币参拜固定是1
                Network.no_loading_rpc(callback, "guild.reward", "guild.reward", subArg, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "guild.getMemberInfo", "guild.getMemberInfo", nil, true)
end

--攻城副本
function guildcopy_attack()
    local curCopyId = 0
    local buy_num = 0
    local recv_pass_reward_time = 0
    local recv_box_reward_time = 0
    local pass_time = 0
    local groupCopyDb = {}
    require "db/DB_GroupCopy"
    local function openBox(p_boxId )
        local requestFunc = function( cbFlag, dictData, bRet )
            if (dictData.err == "ok") then
                showTip("藏宝阁宝箱领取成功")
                finish_table["guildcopy_attack"] = 1
            end
        end
        local args = Network.argsHandler(p_boxId)
        Network.no_loading_rpc(requestFunc, "guildcopy.openBox", "guildcopy.openBox", args, true)
    end
    local function getBoxInfo()
        local requestFunc = function( cbFlag, dictData, bRet )
            if (dictData.err == "ok") then
                -- showTip("getBoxInfo")
                -- printT(dictData)
                local chest = string.split(groupCopyDb.Chest,",")
                local num = 0
                for k,v in pairs(chest) do
                    local tmp = string.split(v,"|")
                    num = num + tonumber(tmp[4])
                end
                for i=1,num do
                    if(dictData.ret[tostring(i)]==nil)then
                        schedule(nil,function() openBox(i) end, 0.2)
                        return
                    end
                end
            end
        end
        Network.no_loading_rpc(requestFunc, "guildcopy.getBoxInfo", "guildcopy.getBoxInfo", nil, true)
    end
    local function recvPassReward()
        local requestFunc = function( cbFlag, dictData, bRet )
            if (dictData.err == "ok") then
                showTip("藏宝阁战功领取成功")
                if(recv_box_reward_time==0)then
                    schedule(nil,getBoxInfo,0.2)
                end
            end
        end
        Network.no_loading_rpc(requestFunc, "guildcopy.recvPassReward", "guildcopy.recvPassReward", nil, true)
    end
    local function attack( p_copyId, p_baseIndex )
        local requestFunc = function( cbFlag, dictData, bRet )
            if (dictData.err == "ok") then
                showTip("攻城副本攻打成功")
                -- printT(dictData)
            end
        end
        local args = Network.argsHandler(p_copyId, p_baseIndex)
        Network.no_loading_rpc(requestFunc, "guildcopy.attack", "guildcopy.attack", args, true)
    end
    local function getCopyInfo(p_copyId )
        local requestFunc = function( cbFlag, dictData, bRet )
            if (dictData.err == "ok") then
                -- printT(dictData)
                for k,v in pairs(dictData.ret)do
                    --未攻打v.hp=nil
                    --已击杀v.hp={}
                    if(v.hp==nil or table.count(v.hp)>0)then
                        -- showTip(k)
                        schedule(nil,function() attack(curCopyId,tonumber(k)) end,0.2)
                        return
                    end
                end
            end
        end
        local args = Network.argsHandler(p_copyId)
        Network.no_loading_rpc(requestFunc, "guildcopy.getCopyInfo", "guildcopy.getCopyInfo", args, true)
    end
        -- /**
    --  * 玩家自己通过购买增加攻击次数
    --  * 
    --  * @return 'ok'/'already_pass'
    --  */
    local function addAtkNum()
        local requestFunc = function( cbFlag, dictData, bRet )
            if (dictData.err == "ok") then
                -- printT(dictData)
                showTip("攻城副本购买攻打次数成功")
                buy_num = buy_num + 1
                local set_num = default_value["guildcopy_addAtkNum"] or 0
                if(buy_num<set_num)then
                    schedule(nil,addAtkNum,0.2)
                    return
                end
                schedule(nil,function() getCopyInfo(curCopyId) end ,0.2)
            end
        end
        Network.no_loading_rpc(requestFunc, "guildcopy.addAtkNum", "guildcopy.addAtkNum", nil, true)
    end
    local function getUserInfo()
        local requestFunc = function( cbFlag, dictData, bRet )
            if (dictData.err == "ok") then
                -- printT(dictData)
                -- showTip("getUserInfo")
                local info = dictData.ret
                pass_time = tonumber(info.pass_time)
                recv_pass_reward_time = tonumber(info.recv_pass_reward_time)
                recv_box_reward_time = tonumber(info.recv_box_reward_time)
                buy_num = tonumber(info.buy_num)
                curCopyId = tonumber(info.curr)
                groupCopyDb = DB_GroupCopy.getDataById(curCopyId)
                local atk_damage = tonumber(info.atk_damage)
                if(pass_time>0)then--已通关
                    if(recv_pass_reward_time==0)then
                        schedule(nil,recvPassReward,0.2)
                        return
                    end
                    if(recv_box_reward_time==0)then
                        schedule(nil,getBoxInfo,0.2)
                        return
                    end
                    finish_table["guildcopy_attack"] = 1
                    showTip("攻城副本已领奖")
                    return
                else
                    if(atk_damage>0)then
                        showTip("攻城副本已攻打")
                        return
                    end
                    local set_num = default_value["guildcopy_addAtkNum"] or 0
                    if(buy_num<set_num)then
                        schedule(nil,addAtkNum,0.2)
                        return
                    end
                    schedule(nil,function() getCopyInfo(curCopyId) end ,0.2)
                end
            end
        end
        Network.no_loading_rpc(requestFunc, "guildcopy.getUserInfo", "guildcopy.getUserInfo", nil, true)
    end
    getUserInfo()
end

-- 关公殿金币参拜
function guild_reward_gold()
    showTip("关公殿金币参拜")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
                        require "script/model/user/UserModel"
    		local nowLevel = dictData.ret.level
            require "db/DB_Legion_feast"
    		local guanGongInfo = DB_Legion_feast.getDataById(1)
    		local growTili = math.floor(guanGongInfo.baseExecution+guanGongInfo.growExecution*nowLevel/100)
    		UserModel.addEnergyValue(growTili)

    		local growNaili = math.floor(guanGongInfo.baseStamina+guanGongInfo.growStamina*nowLevel/100)
    		UserModel.addStaminaNumber(growNaili)

    		local itemNumP = math.floor(guanGongInfo.basePrestige+guanGongInfo.growPrestige*nowLevel/100)
    	    UserModel.addPrestigeNum(tonumber(itemNumP))

    	    local itemNumS = math.floor(guanGongInfo.baseSoul+guanGongInfo.growSoul*nowLevel/100)
    	    UserModel.addSoulNum(tonumber(itemNumS))

    	    local itemNumSi = math.floor(guanGongInfo.baseSilver+guanGongInfo.growSilver*nowLevel/100)
    	    UserModel.addSilverNumber(tonumber(itemNumSi))

    	    local itemNumG = math.floor(guanGongInfo.baseGold+guanGongInfo.growGold*nowLevel/100)
    	    UserModel.addGoldNumber(tonumber(itemNumG))
            showTip("关公殿金币参拜成功，体力+ ".. growTili)
            UserModel.addGoldNumber(-30)
            finish_table["guild_reward_gold"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    require "db/DB_Legion_feast"
    if (TimeUtil.getSvrTimeByOffset() < TimeUtil.getIntervalByTime(tonumber(DB_Legion_feast.getDataById(1).beginTime))) then
        showTip("当前不在关公殿金币参拜时间")
        return
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local reward_buy_num = tonumber(info.reward_buy_num)
            -- prints("reward_buy_num "..reward_buy_num)
            if (reward_buy_num ~= 0) then
                isGet = true
                showTip("关公殿金币参拜，请勿重复参拜")
                finish_table["guild_reward_gold"] = 1
                return
            end
            if (not isGet) then
                local subArg = CCArray:create()
                subArg:addObject(CCInteger:create(1)) -- 免费参拜固定是0，金币参拜固定是1
                Network.no_loading_rpc(callback, "guild.reward", "guild.reward", subArg, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "guild.getMemberInfo", "guild.getMemberInfo", nil, true)
end
-- 小游戏第一关胜利一次
function minigame_gainReward()
    showTip("小游戏第一关")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("小游戏第一关胜利")
            finish_table["minigame_gainReward"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local args = Network.argsHandlerOfTable({100001}) -- 关卡id 100001(第1关）~ 100015（第15关）
    Network.no_loading_rpc(callback, "minigame.gainReward", "minigame.gainReward", args, true)
end
-- 小游戏胜利10次代码
function minigame_gainReward10()
    schedule(CCDirector:sharedDirector():getRunningScene(), minigame_gainReward, 0.5, 10)
end
-- 小游戏胜利100次代码
function minigame_gainReward100()
    schedule(CCDirector:sharedDirector():getRunningScene(), minigame_gainReward, 0.5, 100)
end
-- schedule(CCDirector:sharedDirector():getRunningScene(),minigame_gainReward,1,100)

function getActiveCopyData(id)
    local data = DataCache.getActiveCopyData()
    for k,v in pairs(data) do
        if(tonumber(v.copy_id) == tonumber(id))then
            return v
        end
    end
    return nil
end
local acopy_atkGoldTree_num = 1
-- 摇钱树扫荡
function acopy_atkGoldTree()
    showTip("摇钱树")
    
    if getActiveCopyData(300001).copyInfo.limit_lv > UserModel.getHeroLevel() then
        showTip("摇钱树，等级未达到")
        return 
    end
    acopy_atkGoldTree_num = 1
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("摇钱树扫荡成功")
            acopy_atkGoldTree_num = acopy_atkGoldTree_num + 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            DataCache.setActiveCopyData(info)
            local num = tonumber(info["300001"].can_defeat_num)
            -- prints("300001 num "..num)
            if (num == 0) then
                isGet = true
                showTip("摇钱树，请勿重复攻打")
                finish_table["acopy_atkGoldTree"] = 1
                return
            end

            local attack = function()
                if (acopy_atkGoldTree_num > num) then
                    showTip("摇钱树扫荡完毕")
                    finish_table["acopy_atkGoldTree"] = 1
                    return
                end
                showTip("摇钱树扫攻打" .. acopy_atkGoldTree_num .. "/" .. num)
                local args = Network.argsHandlerOfTable({300001, 0}) -- 摇钱树副本id 300001；0表示使用攻击次数，1表示使用物品
                Network.no_loading_rpc(callback, "acopy.atkGoldTree", "acopy.atkGoldTree", args, true)
            end
            if (not isGet) then
                schedule(CCDirector:sharedDirector():getRunningScene(), attack, 0.3, num)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "acopy.getCopyList", "acopy.getCopyList", nil, true)
end
-- 经验宝物扫荡
function acopy_sweep1()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("经验宝物扫荡")
    if getActiveCopyData(300002).copyInfo.limit_lv > UserModel.getHeroLevel() then
        showTip("经验宝物，等级未达到")
        return 
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("经验宝物扫荡成功")
            finish_table["acopy_sweep1"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local num = tonumber(info["300002"].can_defeat_num)
            require "db/DB_Activitycopy"
            local dbCopyInfo = DB_Activitycopy.getDataById(300002)
            local baseId = tonumber(dbCopyInfo.fort_ids)
            -- prints("300002 num " .. num)
            -- prints("300002 baseId " .. baseId)
            if (num == 0) then
                isGet = true
                showTip("经验宝物，请勿重复攻打")
                finish_table["acopy_sweep1"] = 1
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({300002, baseId, num}) -- 经验宝物副本id 300002，
                Network.no_loading_rpc(callback, "acopy.sweep", "acopy.sweep", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "acopy.getCopyList", "acopy.getCopyList", nil, true)
end
-- 经验熊猫扫荡
function acopy_sweep2()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("经验熊猫扫荡")
    if getActiveCopyData(300004).copyInfo.limit_lv > UserModel.getHeroLevel() then
        showTip("经验熊猫，等级未达到")
        return 
    end

    if (not CopyUtil.isHeroExpCopyOpen()) then
        showTip("经验熊猫未开始")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("经验熊猫扫荡成功")
            finish_table["acopy_sweep2"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local num = tonumber(info["300004"].can_defeat_num)
            require "db/DB_Activitycopy"
            local dbCopyInfo = DB_Activitycopy.getDataById(300004)
            local baseId = tonumber(dbCopyInfo.fort_ids)
            -- prints("300004 num " .. num)
            -- prints("300004 baseId " .. baseId)
            if (num == 0) then
                isGet = true
                showTip("经验熊猫，请勿重复攻打")
                finish_table["acopy_sweep2"] = 1
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({300004, baseId, num}) -- 经验熊猫副本id 300004
                Network.no_loading_rpc(callback, "acopy.sweep", "acopy.sweep", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "acopy.getCopyList", "acopy.getCopyList", nil, true)
end
-- 经验副本扫荡
function acopy_sweep3()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("经验副本扫荡")
    if getActiveCopyData(300005).copyInfo.limit_lv > UserModel.getHeroLevel() then
        showTip("经验副本，等级未达到")
        return 
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("经验副本扫荡成功")
            finish_table["acopy_sweep3"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local num = tonumber(info["300005"].can_defeat_num)
            local base_id = tonumber(info["300005"].va_copy_info.pass_base_id)
            -- prints("300005 num " .. num)
            -- prints("300005 baseId " .. base_id)
            if (num == 0) then
                isGet = true
                showTip("经验副本，请勿重复攻打")
                finish_table["acopy_sweep3"] = 1
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({300005, base_id, num}) -- 经验副本id 300005
                Network.no_loading_rpc(callback, "acopy.sweep", "acopy.sweep", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "acopy.getCopyList", "acopy.getCopyList", nil, true)
end
-- 天命副本扫荡
function acopy_sweep4()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("天命副本扫荡")
    if getActiveCopyData(300006).copyInfo.limit_lv > UserModel.getHeroLevel() then
        showTip("天命副本，等级未达到")
        return 
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("天命副本扫荡成功")
            finish_table["acopy_sweep4"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local num = tonumber(info["300006"].can_defeat_num)
            require "db/DB_Activitycopy"
            local dbCopyInfo = DB_Activitycopy.getDataById(300006)
            local baseId = tonumber(dbCopyInfo.fort_ids)
            -- prints("300006 num " .. num)
            -- prints("300006 baseId " .. baseId)
            if (num == 0) then
                isGet = true
                showTip("天命副本，请勿重复攻打")
                finish_table["acopy_sweep4"] = 1
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({300006, baseId, num}) -- 天命副本id 300006
                Network.no_loading_rpc(callback, "acopy.sweep", "acopy.sweep", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "acopy.getCopyList", "acopy.getCopyList", nil, true)
end
-- 战魂副本扫荡
function acopy_sweep5()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("战魂副本扫荡")
    if getActiveCopyData(300007).copyInfo.limit_lv > UserModel.getHeroLevel() then
        showTip("战魂副本，等级未达到")
        return 
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("战魂副本扫荡成功")
            finish_table["acopy_sweep5"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local num = tonumber(info["300007"].can_defeat_num)
            require "db/DB_Activitycopy"
            local dbCopyInfo = DB_Activitycopy.getDataById(300007)
            local baseId = tonumber(dbCopyInfo.fort_ids)
            -- prints("300007 num " .. num)
            -- prints("300007 baseId " .. baseId)
            if (num == 0) then
                isGet = true
                showTip("战魂副本，请勿重复攻打")
                finish_table["acopy_sweep5"] = 1
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({300007, baseId, num}) -- 战魂副本id 300007 
                Network.no_loading_rpc(callback, "acopy.sweep", "acopy.sweep", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "acopy.getCopyList", "acopy.getCopyList", nil, true)
end
-- 占星台
function divine_oneClickDivine()
    showTip("占星台")
    if not DataCache.getSwitchNodeState(ksSwitchStar, false) then
        showTip("占星台，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("占星成功")
            finish_table["divine_oneClickDivine"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local num = tonumber(info.divi_times)
            if (num ~= 0) then
                isGet = true
                showTip("占星台，请勿重复占星")
                finish_table["divine_oneClickDivine"] = 1
                return
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "divine.oneClickDivine", "divine.oneClickDivine", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "divine.getDiviInfo", "divine.getDiviInfo", CCArray:create(), true)
end

-- 占星台领奖
function divine_drawPrizeAll()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("占星台领奖")
    if not DataCache.getSwitchNodeState(ksSwitchStar, false) then
        showTip("占星台，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("占星领奖成功")
            finish_table["divine_drawPrizeAll"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local num = tonumber(info.divi_times)
            local prize_step = tonumber(info.prize_step)
            if (prize_step < 10) then
                Network.no_loading_rpc(callback, "divine.drawPrizeAll", "divine.drawPrizeAll", nil, true)
            else
                showTip("占星台已领奖")
                finish_table["divine_drawPrizeAll"] = 1
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "divine.getDiviInfo", "divine.getDiviInfo", CCArray:create(), true)
end
-- 宠物一键领取
function pet_collectAllProduction()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("宠物物品")
    require "script/ui/pet/PetUtil"
    require "script/ui/pet/PetData"
    local updatePetDataById = function ( pPetIds )
		if table.isEmpty(pPetIds) then
			prints("collectProduction pPetIds is empty")
			return
		end
		local nSvrTime = BTUtil:getSvrTimeInterval()
		for k, nPetId in pairs(pPetIds) do
			local petInfo = PetData.getPetInfoById(tonumber(nPetId))
			local skillId= tonumber(petInfo.va_pet.skillProduct[1].id ) 
			local level = PetData.getPetSkillLevel( tonumber(nPetId) ) --tonumber(petInfo.va_pet.skillProduct[1].level )
			PetUtil.addProduceItem(skillId, level)
			PetData.setProducttimeById(tonumber(nPetId), nSvrTime)
		end
	end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            if dictData.ret.err == "ok" then
                showTip("宠物物品领取成功")
                updatePetDataById(dictData.ret.petIdsArr)
            elseif dictData.ret.err == "addProErr" then
				--领取失败
				showTip("宠物物品领取失败")
				return
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = true
            local info = dictData.ret
            local time = 99999999999
            PetData.setAllPetInfo(info)
            for k, v in ipairs(info.keeperInfo.va_keeper.setpet) do
                if tonumber(v.petid) > 0 then -- 当宠物栏位开启，但没有添加宠物时，v.petid=0
                    local nLeftTime = PetData.getLeftProducttimeBySet(v)
                    if(time>nLeftTime)then
                        time = nLeftTime
                    end
                end
            end
            --prints("time " ..time)
            local nCanReceive, sDesc = PetData.canOneKeyReceive()
            if(nCanReceive==0)then
                isGet = false
                showTip("可以领取")
            else
                showTip(sDesc)
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "pet.collectAllProduction", "pet.collectAllProduction", nil, true)
                return
            else
                showTip("宠物物品，请勿重复领取")
                return
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "pet.getAllPet", "pet.getAllPet", nil, true)
end
-- 好友一键赠送体力
function friend_oneKeyLoe()
    showTip("好友赠送体力")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("好友赠送体力成功")
            schedule(CCDirector:sharedDirector():getRunningScene(), friend_oneKeyLoe, 0.1)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = true
            local info = dictData.ret
            for i = 1, #info do
                local lovedTime = info[i].lovedTime
                local curTIme = TimeUtil.getSvrTimeByOffset(0)
                if (not TimeUtil.isSameDay(lovedTime, curTIme)) then
                    isGet = false
                end
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "friend.oneKeyLove", "friend.oneKeyLove", nil, true)
                return
            else
                showTip("好友已全部赠送体力，请勿重复赠送")
                finish_table["friend_oneKeyLoe"] = 1
                return
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "friend.getFriendInfoList", "friend.getFriendInfoList", nil, true)
end
--水月普通副本购买次数
function moon_addAttackNum1()
    showTip("水月普通副本购买次数")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("水月普通副本购买次数成功")
            schedule(CCDirector:sharedDirector():getRunningScene(), moon_addAttackNum2, 0.2)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local buy_num = tonumber(info.buy_num)
            local num = tonumber(default_value["moon_addAttackNum1"]) or 1
            if (buy_num >= num) then
                isGet = true
                showTip("水月普通副本，请勿重复购买")
                finish_table["moon_addAttackNum1"] = 1
                return
            end
            if (not isGet) then
                local args = Network.argsHandler(0) -- 0是购买普通次数，1是购买梦魇次数
                Network.no_loading_rpc(callback, "moon.addAttackNum", "moon.addAttackNum", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "moon.getMoonInfo", "moon.getMoonInfo", nil, true)
end
-- 水月之境水月副本扫荡
function moon_sweep1()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("水月副本")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("水月副本扫荡成功")
            finish_table["moon_sweep1"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local max_level = tonumber(info.max_pass_copy)
            local num = tonumber(info.atk_num)
            if (num == 0) then
                isGet = true
                showTip("水月副本，请勿重复扫荡")
                finish_table["moon_sweep1"] = 1
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({max_level, 0}) -- 副本层数；0是普通副本，1是梦魇副本
                Network.no_loading_rpc(callback, "moon.sweep", "moon.sweep", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "moon.getMoonInfo", "moon.getMoonInfo", nil, true)
end

-- 水月之境梦魇副本购买1次
function moon_addAttackNum2()
    showTip("水月梦魇副本购买次数")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("水月梦魇副本购买次数成功")
            schedule(CCDirector:sharedDirector():getRunningScene(), moon_addAttackNum2, 0.2)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local nightmare_buy_num = tonumber(info.nightmare_buy_num)
            local num = tonumber(default_value["moon_addAttackNum2"]) or 1
            if (nightmare_buy_num >= num) then
                isGet = true
                showTip("水月梦魇副本，请勿重复购买")
                finish_table["moon_addAttackNum2"] = 1
                return
            end
            if (not isGet) then
                local args = Network.argsHandler(1) -- 0是购买普通次数，1是购买梦魇次数
                Network.no_loading_rpc(callback, "moon.addAttackNum", "moon.addAttackNum", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "moon.getMoonInfo", "moon.getMoonInfo", nil, true)
end
-- 水月之境梦魇副本扫荡
function moon_sweep2()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("水月梦魇副本")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("水月梦魇副本扫荡成功")
            finish_table["moon_sweep2"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local max_level = tonumber(info.max_nightmare_pass_copy)
            local num = tonumber(info.nightmare_atk_num)
            if (num == 0) then
                isGet = true
                showTip("水月梦魇副本，请勿重复扫荡")
                finish_table["moon_sweep2"] = 1
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({max_level, 1}) -- 副本层数；0是普通副本，1是梦魇副本
                Network.no_loading_rpc(callback, "moon.sweep", "moon.sweep", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "moon.getMoonInfo", "moon.getMoonInfo", nil, true)
end
-- 道具商店购买1个体力丹
function shop_buyGoods1()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("道具商店体力丹")
    local num = tonumber(default_value["shop_buyGoods1"]) or 1
    if(num<=0)then
        return
    end
    local totalPrice = 0
    require "script/ui/shop/ShopUtil"
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("道具商店购买体力丹成功")
            finish_table["shop_buyGoods1"] = 1
			UserModel.addGoldNumber(-totalPrice)
			DataCache.addBuyNumberBy( 1, num )
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            if (info.goods["1"] ~= nil) then
                if(tonumber(info.goods["1"].num)>=num)then
                    isGet = true
                    showTip("道具商店耐力丹已购买，请勿重复购买")
                    finish_table["shop_buyGoods1"] = 1
                    return
                else
                    num = num - tonumber(info.goods["1"].num)
                end
            end
            totalPrice = ShopUtil.getNeedGoldByMoreGoods( 1, ShopUtil.getBuyNumBy(1)+1, num)
            if (not isGet) then
                local args = Network.argsHandler(1, num) -- 体力丹id；购买数量
                Network.no_loading_rpc(callback, "shop.buyGoods", "shop.buyGoods", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "shop.getShopInfo", "shop.getShopInfo", nil, true)
end
-- 道具商店购买1个耐力丹
function shop_buyGoods2()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("道具商店耐力丹")
    local num = tonumber(default_value["shop_buyGoods2"]) or 2
    if(num<=0)then
        return
    end
    local totalPrice = 0
    require "script/ui/shop/ShopUtil"
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("道具商店购买耐力丹成功")
            finish_table["shop_buyGoods2"] = 1
            UserModel.addGoldNumber(-totalPrice)
			DataCache.addBuyNumberBy( 2, num )
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            if (info.goods["2"] ~= nil) then
                if(tonumber(info.goods["2"].num)>=num)then
                    isGet = true
                    showTip("道具商店耐力丹已购买，请勿重复购买")
                    finish_table["shop_buyGoods2"] = 1
                    return
                else
                    num = num - tonumber(info.goods["2"].num)
                end
            end
            totalPrice = ShopUtil.getNeedGoldByMoreGoods( 2, ShopUtil.getBuyNumBy(2)+1, num)
            if (not isGet) then
                local args = Network.argsHandler(2, num) -- 耐力丹id；购买数量
                Network.no_loading_rpc(callback, "shop.buyGoods", "shop.buyGoods", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "shop.getShopInfo", "shop.getShopInfo", nil, true)
end

-- 道具商店购买666大礼包
function shop_buyGoods18()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("道具商店666大礼包")
    local num = tonumber(default_value["shop_buyGoods18"]) or 0
    if(num<=0)then
        return
    end
    if(num>=1)then
        num = 1 
    end
    local totalPrice = 666
    require "script/ui/shop/ShopUtil"
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("道具商店购买666大礼包成功")
            finish_table["shop_buyGoods18"] = 1
            UserModel.addGoldNumber(-totalPrice)
			DataCache.addBuyNumberBy( 18, num )
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            if (info.goods["18"] ~= nil) then
                if(tonumber(info.goods["18"].num)>=num)then
                    isGet = true
                    showTip("道具商店666大礼包已购买，请勿重复购买")
                    finish_table["shop_buyGoods18"] = 1
                    return
                else
                    num = num - tonumber(info.goods["18"].num)
                end
            end
            totalPrice = ShopUtil.getNeedGoldByMoreGoods( 18, ShopUtil.getBuyNumBy(18)+1, num)
            if (not isGet) then
                local args = Network.argsHandler(18, num) -- 666大礼包id；购买数量
                Network.no_loading_rpc(callback, "shop.buyGoods", "shop.buyGoods", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "shop.getShopInfo", "shop.getShopInfo", nil, true)
end

-- 酒馆良将招募
function shop_silverRecruit()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("酒馆良将招募")
    local num = 0
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("酒馆良将招募成功")
            DataCache.addSiliverFreeNum(-1)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            num = tonumber(info.silver_recruit_num)
            local silver_recruit_time = tonumber(info.silver_recruit_time)
            if (num == 0) then
                isGet = true
                showTip("酒馆良将已招募，请勿重复招募")
                if(TimeUtil.getDifferDay(TimeUtil.getSvrTimeByOffset()+silver_recruit_time)~=0)then
                    finish_table["shop_silverRecruit"] = 1
                end
                return
            end
            if (not isGet) then
                local args = Network.argsHandler(0) -- 0是使用免费次数，1是使用招贤币
                Network.no_loading_rpc(callback, "shop.silverRecruit", "shop.silverRecruit", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "shop.getShopInfo", "shop.getShopInfo", nil, true)
end

-- 酒馆神将招募
function shop_goldRecruit()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("酒馆神将招募")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("酒馆神将招募成功")
            finish_table["shop_goldRecruit"] = 1
            DataCache.addGoldFreeNum(-1)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local num = tonumber(info.gold_recruit_num)
            local gold_recruit_time = tonumber(info.gold_recruit_time)
            if (num == 0) then
                isGet = true
                showTip("酒馆神将已招募，请勿重复招募")
                if(TimeUtil.getDifferDay(TimeUtil.getSvrTimeByOffset()+gold_recruit_time)~=0)then
                    finish_table["shop_goldRecruit"] = 1
                end
                return
            end
            if (not isGet) then
                local args = Network.argsHandler(0, 1) -- 0是使用免费次数，1是使用招贤币；招募次数
                Network.no_loading_rpc(callback, "shop.goldRecruit", "shop.goldRecruit", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "shop.getShopInfo", "shop.getShopInfo", nil, true)
end
-- 猎魂1000w银币（不留五星魂）
function hunt_rapidHunt()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("猎魂1000w")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("猎魂1000w成功")
            finish_table["hunt_rapidHunt"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            if (info.va_active.task["18"] ~= nil and tonumber(info.va_active.task["18"]) >= 2) then
                isGet = true
                showTip("已猎魂1000w，请勿重复猎魂")
                finish_table["hunt_rapidHunt"] = 1
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({1}) -- {选择银币档位1~4, {保留品质4,5}}
                Network.no_loading_rpc(callback, "hunt.rapidHunt", "hunt.rapidHunt", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "active.getActiveInfo", "active.getActiveInfo", nil, true)
end
-- 每日签到
function sign_gainNormalSignReward()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("每日签到")
    if not DataCache.getSwitchNodeState(ksSwitchSignIn, false) then
        showTip("每日签到，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("每日签到成功")
            finish_table["sign_gainNormalSignReward"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local sign_num = info.sign_num
            local sign_day = 0
            for k, v in pairs(info.normal_list) do
                if (tonumber(v) == 0) then
                    sign_day = tonumber(k)
                end
            end
            if (sign_day == 0) then
                isGet = true
                showTip("每日签到，请勿重复签到")
                finish_table["sign_gainNormalSignReward"] = 1
                return
            end
            if (not isGet) then
                local args = CCArray:create()
                args:addObject(CCInteger:create(sign_day)) -- 领取第几天签到奖励
                Network.no_loading_rpc(callback, "sign.gainNormalSignReward", "sign.gainNormalSignReward", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "sign.getNormalInfo", "sign.getNormalInfo", nil, true)
end

-- 主角学习技能
function star_quickDraw()
    showTip("主角学习技能")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("主角学习技能成功")
            finish_table["star_quickDraw"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            require "db/DB_Teach"
            require "db/DB_Star"
            local teachInfo = DB_Teach.getDataById(1)
            local freeNum = 0
            if info ~= nil and tonumber(info.allStarInfo.draw_num) < tonumber(teachInfo.drawNum) then
                freeNum = tonumber(teachInfo.drawNum) - tonumber(info.allStarInfo.draw_num)
            end
            if (freeNum == 0) then
                isGet = true
                showTip("主角学习技能，请勿重复操作")
                finish_table["star_quickDraw"] = 1
                return
            end
            local star_list = info.allStarInfo.star_list

            for k, v in pairs(star_list) do
                local starTemplate = DB_Star.getDataById(tonumber(v.star_tid)).isFeel
                if (starTemplate ~= nil and starTemplate == 1) then
                    -- prints("starTemplate "..starTemplate)
                    if (tonumber(v.feel_level) < 60) then
                        if (not isGet) then
                            local args = CCArray:create()
                            args:addObject(CCInteger:create(tonumber(v.star_id))) -- 技能对应武将id
                            Network.no_loading_rpc(callback, "star.quickDraw", "star.quickDraw", args, true)
                            return
                        end
                    end
                end
            end
            if (not isGet) then
                showTip("主角暂无技能可以学习")
                finish_table["star_quickDraw"] = 1
                return
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "star.getAllStarInfo", "star.getAllStarInfo", nil, true)
end

-- 将士送礼
function star_addFavorByAllGifts()
    showTip("将士送礼")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("将士送礼成功")
            finish_table["star_addFavorByAllGifts"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            if (info.va_active.task["24"] ~= nil and tonumber(info.va_active.task["24"]) >= 3) then
                isGet = true
                showTip("将士已送礼，请勿重复操作")
                finish_table["star_addFavorByAllGifts"] = 1
                return
            end
            local info_callback = function(cbFlag, dictData, bRet)
                if (dictData.err == "ok") then
                    local info = dictData.ret
                    local star_list = info.allStarInfo.star_list
                    local send_gift_hero_id = 0
                    for k, v in pairs(star_list) do
                        send_gift_hero_id = tonumber(v.star_id)
                        if (tonumber(v.level) < 35) then
                            send_gift_hero_id = tonumber(v.star_id)
                            break
                        end
                    end
                    local args = Network.argsHandler(send_gift_hero_id) -- 武将id
                    Network.no_loading_rpc(callback, "star.addFavorByAllGifts", "star.addFavorByAllGifts", args, true)
                end
            end
            if (not isGet) then
                Network.no_loading_rpc(info_callback, "star.getAllStarInfo", "star.getAllStarInfo", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "active.getActiveInfo", "active.getActiveInfo", nil, true)
end
-- 普通试炼塔重置
function tower_resetTower1()
    showTip("普通试炼塔重置")
    local num = 0
    if not DataCache.getSwitchNodeState(ksSwitchTower, false) then
        showTip("普通试炼塔，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            num = num - 1
            showTip("普通试炼塔重置成功，剩余".. num .."次")
            schedule(nil,tower_sweep1,0.1)
            if(num <= 0)then
                isGet = true
                finish_table["tower_resetTower1"] = 1
                return
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            num = tonumber(info.reset_num)
            -- prints("info.cur_level "..info.cur_level)
            -- prints("info.max_level "..info.max_level)
            -- prints("info.reset_num "..info.reset_num)
            -- prints("info.cur_status "..info.va_tower_info.cur_status)
            if(tonumber(info.reset_num) == 0)then
                isGet = true
                showTip("免费重置次数用完，重置失败")
                finish_table["tower_resetTower1"] = 1
                return
            end
            if (tonumber(info.cur_level) ~= tonumber(info.max_level) or
                tonumber(info.va_tower_info.cur_status) == 0) then
                isGet = true
                showTip("当前不在最高层，重置失败")
                return
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "tower.resetTower", "tower.resetTower", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "tower.getTowerInfo", "tower.getTowerInfo", nil, true)
end
-- 普通试炼塔极速扫荡
function tower_defeatMonster1()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("普通试炼塔扫荡")
    if not DataCache.getSwitchNodeState(ksSwitchTower, false) then
        showTip("普通试炼塔，等级未达到")
        return
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local cur_level = tonumber(info.cur_level)
            local max_level = tonumber(info.max_level)
            local cur_status = tonumber(info.va_tower_info.cur_status)
            local enter = nil
            local enter_callback = nil
            local attack = nil
            local attack_callback = nil
            -- prints("cur_level "..cur_level)
            -- prints("max_level "..max_level)
            if (cur_level >= max_level and cur_status == 1) then
                isGet = true
                showTip("普通试炼塔已达到最高层")
                return
            end
            local sweep_info = info.va_tower_info.sweep_info
            if (not table.isEmpty(sweep_info)) then
                isGet = true
                showTip("普通试炼塔停止扫荡")
                local requestCallback = function(cbFlag,dictData,bRet)
                    if dictData.err == "ok" then
                        tower_defeatMonster1()
                    end
                end
                local args = Network.argsHandlerOfTable({ 1 })--(1：普通试练塔 2：试炼梦魇)
                Network.no_loading_rpc(requestCallback,"tower.endSweep","tower.endSweep",args,true)
                return
            end
            local num = max_level - cur_level
            if (cur_status == 0) then
                num = num + 1
            end
            attack_callback = function(cbFlag, dictData, bRet)
                if (dictData.err == "ok") then
                    showTip("普通试炼塔"..cur_level.."层攻打成功")
                    cur_level = cur_level + 1
                    schedule(CCDirector:sharedDirector():getRunningScene(), enter, 0)
                else
                    printT(dictData)
                    showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
                end
            end
            attack = function()
                showTip("攻打普通试炼塔" .. cur_level .. "/" .. max_level)
                require "db/DB_Tower_layer"
                local pArmyId = DB_Tower_layer.getDataById(cur_level).stronghold
                local args = Network.argsHandlerOfTable({cur_level, pArmyId}) -- 当前层；当前层副本id
                Network.no_loading_rpc(attack_callback, "tower.defeatMonster", "tower.defeatMonster", args, true)
                -- cur_level = cur_level + 1
            end
            enter_callback = function(cbFlag, dictData, bRet)
                if (dictData.err == "ok") then
                    schedule(CCDirector:sharedDirector():getRunningScene(), attack, 0.1)
                end
            end
            enter = function()
                local args = Network.argsHandlerOfTable({cur_level})
                Network.no_loading_rpc(enter_callback, "tower.enterLevel", "tower.enterLevel", args, true)
            end
            if (not isGet) then
                enter()
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "tower.getTowerInfo", "tower.getTowerInfo", nil, true)
end

-- 普通试炼塔扫荡
function tower_sweep1()
    showTip("普通试炼塔扫荡")
    if not DataCache.getSwitchNodeState(ksSwitchTower, false) then
        showTip("普通试炼塔，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("普通试炼塔开始扫荡")
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local cur_level = tonumber(info.cur_level)
            local max_level = tonumber(info.max_level)
            local cur_status = tonumber(info.va_tower_info.cur_status)
            if (cur_level >= max_level and cur_status == 1) then
                isGet = true
                showTip("普通试炼塔已达到最高层")
                return
            end
            local sweep_info = info.va_tower_info.sweep_info
            if (not table.isEmpty(sweep_info)) then
                isGet = true
                showTip("普通试炼塔正在扫荡")
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({cur_level, max_level}) -- 当前层；最大层
                Network.no_loading_rpc(callback, "tower.sweep ", "tower.sweep", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "tower.getTowerInfo", "tower.getTowerInfo", nil, true)
end
-- 梦魇试炼塔重置
function tower_resetTower2()
    showTip("梦魇试炼塔重置")
    local num = 0
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            num = num - 1
            showTip("梦魇试炼塔免费重置成功，剩余"..num.."次")
            schedule(nil,tower_sweep2,0.1)
            if(num <= 0)then
                finish_table["tower_resetTower2"] = 1
                return
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            num = tonumber(info.reset_hell)
            if(tonumber(info.reset_hell) == 0)then
                isGet = true
                showTip("免费重置次数用完，重置失败")
                finish_table["tower_resetTower2"] = 1
                return
            end
            if (tonumber(info.cur_hell) ~= tonumber(info.max_hell) or
                tonumber(info.va_tower_info.cur_hell_status == 0)) then
                isGet = true
                showTip("当前不在最高层，重置失败")
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({2}) -- 梦魇试练塔固定是2
                Network.no_loading_rpc(callback, "tower.resetTower", "tower.resetTower", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "tower.getTowerInfo", "tower.getTowerInfo", nil, true)
end
-- 梦魇试炼塔金币重置
function tower_resetTower_gold2()
    showTip("梦魇试炼塔重置")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("梦魇试炼塔免费重置成功")
            schedule(nil,tower_sweep2,0.1)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local buyAtkNum_callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("梦魇试炼塔金币重置成功")
            schedule(nil,tower_sweep2,0.1)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local buyAtkNum = function()
        local args = Network.argsHandlerOfTable({1, 2}) -- 购买次数；类型 2是梦魇试炼
        Network.no_loading_rpc(buyAtkNum_callback, "tower.buyAtkNum", "tower.buyAtkNum", args, true)
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            if (tonumber(info.cur_hell) ~= tonumber(info.max_hell) or tonumber(info.va_tower_info.cur_hell_status == 0)) then
                isGet = true
                showTip("当前不在最高层，重置失败")
                return
            end
            require "db/DB_Nightmare_tower"
            local maxBuyTimes = DB_Nightmare_tower.getDataById(1).resetMaxTimes
            local hadBuyTimes = tonumber(info.buy_hell_num)
            local num = maxBuyTimes - hadBuyTimes
            if (num <= 0) then
                showTip("金币重置次数已用完")
                return
            end
            if (tonumber(info.reset_hell) == 0) then
                showTip("免费次数已用完，使用金币重置，剩余金币重置次数：" .. num)
                buyAtkNum()
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({2}) -- 梦魇试练塔固定是2
                Network.no_loading_rpc(callback, "tower.resetTower", "tower.resetTower", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "tower.getTowerInfo", "tower.getTowerInfo", nil, true)
end

-- 梦魇试炼塔极速扫荡
function tower_defeatMonster2()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("梦魇试炼塔扫荡")
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local cur_level = tonumber(info.cur_hell)
            local max_level = tonumber(info.max_hell)
            local cur_status = tonumber(info.va_tower_info.cur_hell_status)
            local enter = nil
            local enter_callback = nil
            local attack = nil
            local attack_callback = nil
            if (cur_level >= max_level and cur_status == 1) then
                isGet = true
                showTip("梦魇试炼塔已达到最高层")
                return
            end
            local sweep_info = info.va_tower_info.sweep_hell_info
            if (not table.isEmpty(sweep_info)) then
                isGet = true
                showTip("梦魇试炼塔停止扫荡")
                local requestCallback = function(cbFlag,dictData,bRet)
                    if dictData.err == "ok" then
                        tower_defeatMonster2()
                    end
                end
                local args = Network.argsHandlerOfTable({ 2 })--(1：普通试练塔 2：试炼梦魇)
                Network.no_loading_rpc(requestCallback,"tower.endSweep","tower.endSweep",args,true)
                return
            end
            local num = max_level - cur_level
            if (cur_status == 0) then
                num = num + 1
            end
            attack_callback = function(cbFlag, dictData, bRet)
                if (dictData.err == "ok") then
                    showTip("梦魇试炼塔"..cur_level.."层攻打成功")
                    cur_level = cur_level + 1
                    schedule(CCDirector:sharedDirector():getRunningScene(), enter, 0)
                else
                    printT(dictData)
                    showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
                end
                
            end
            attack = function()
                showTip("攻打梦魇试炼塔" .. cur_level .. "/" .. max_level)
                require "db/DB_Nightmare_layer"
                local pArmyId = DB_Nightmare_layer.getDataById(cur_level).stronghold
                local args = Network.argsHandlerOfTable({cur_level, pArmyId, 2})
                Network.no_loading_rpc(attack_callback, "tower.defeatMonster", "tower.defeatMonster", args, true)
                -- cur_level = cur_level + 1
            end
            enter_callback = function(cbFlag, dictData, bRet)
                if (dictData.err == "ok") then
                    schedule(CCDirector:sharedDirector():getRunningScene(), attack, 0.1)
                end
            end
            enter = function()
                local args = Network.argsHandlerOfTable({cur_level, 2})
                Network.no_loading_rpc(enter_callback, "tower.enterLevel", "tower.enterLevel", args, true)
            end
            if (not isGet) then
                enter()
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "tower.getTowerInfo", "tower.getTowerInfo", nil, true)
end
-- 梦魇试炼塔扫荡
function tower_sweep2()
    showTip("梦魇试炼塔扫荡")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("梦魇试炼塔攻打成功")
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local cur_level = tonumber(info.cur_hell)
            local max_level = tonumber(info.max_hell)
            local cur_status = tonumber(info.va_tower_info.cur_hell_status)
            if (cur_level >= max_level and cur_status == 1) then
                isGet = true
                showTip("梦魇试炼塔已达到最高层")
                return
            end
            local sweep_info = info.va_tower_info.sweep_hell_info
            if (not table.isEmpty(sweep_info)) then
                isGet = true
                showTip("梦魇试炼塔正在扫荡")
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({cur_level, max_level, 2})
                Network.no_loading_rpc(callback, "tower.sweep ", "tower.sweep", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "tower.getTowerInfo", "tower.getTowerInfo", nil, true)
end

function end_copyteam_atkWithOfflineHelp()
    showTip("攻打军机大厅完毕")
    -- require "script/network/PreRequest"
    -- Network.re_rpc( PreRequest.pushCopyteamBattleResultCallback, "push.copyteam.battleResult", "push.copyteam.battleResult")
end


-- 军机大厅扫荡
function copyteam_atkWithOfflineHelp()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("军机大厅")
    local members = {} -- 队友信息
    local copyteam_atkWithOfflineHelp_num = 1
    local atk_num = 0
    local cur_guild_copy = 0
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("军机大厅攻打成功")
            copyteam_atkWithOfflineHelp_num = copyteam_atkWithOfflineHelp_num + 1
            schedule(CCDirector:sharedDirector():getRunningScene(), atk_copy_team, 0.2)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    function atk_copy_team()
        if (copyteam_atkWithOfflineHelp_num > atk_num) then
            finish_table["start_copyteam_atkWithOfflineHelp"] = 1
            end_copyteam_atkWithOfflineHelp()
            return
        end
        showTip("军机大厅攻打" .. copyteam_atkWithOfflineHelp_num .. "/" .. atk_num)
        local team_member_id = {}
        for k, v in pairs(members) do
            table.insert(team_member_id, v.uid)
        end
        local args = Network.argsHandlerOfTable({cur_guild_copy, team_member_id})
        -- local team_member_id1 = dictData.ret.members[1].uid
        -- local team_member_id2 = dictData.ret.members[2].uid
        -- local args = Network.argsHandlerOfTable({cur_guild_copy, {team_member_id1,team_member_id2}})
        Network.no_loading_rpc(callback, "copyteam.atkWithOfflineHelp", "copyteam.atkWithOfflineHelp",args, true)
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            cur_guild_copy = tonumber(info.va_copy_team.cur_passed_guild_copy)
            if(cur_guild_copy == nil)then
                showTip("当前无已通关军团副本，无法扫荡")
                return 
            end
            local guild_atk_num = tonumber(info.guild_atk_num)
            local guild_help_num = tonumber(info.guild_help_num)
            require "db/DB_Legion_copy"
            local legionCopy = DB_Legion_copy.getDataById(1)
            local leftHelpNum = legionCopy.helpNum - guild_help_num
            atk_num = guild_atk_num + leftHelpNum
            if (atk_num <= 0) then
                isGet = true
                showTip("军机大厅次数用尽，请勿重复攻打")
                finish_table["start_copyteam_atkWithOfflineHelp"] = 1
                end_copyteam_atkWithOfflineHelp()
                return
            end
            
            local team_callback = function(cbFlag, dictData, bRet)
                if (dictData.err == "ok") then
                    members = dictData.ret.members
                    schedule(CCDirector:sharedDirector():getRunningScene(), atk_copy_team, 0.2)
                end
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({cur_guild_copy})
                Network.no_loading_rpc(team_callback, "copyteam.createOfflineTeam", "copyteam.createOfflineTeam", args, true)
            end
        end
    end
    local args = CCArray:create()
    -- 这里的1 是：副本组队类型暂时只有一种组队类型 1.公会副本组队
    args:addObject(CCInteger:create(1))
    Network.no_loading_rpc(requestFunc, "copyteam.getCopyTeamInfo", "copyteam.getCopyTeamInfo", args, true)
end
function start_copyteam_atkWithOfflineHelp()
    showTip("开始攻打军机大厅")
    Network.remove_re_rpc("push.copyteam.battleResult")
    schedule(CCDirector:sharedDirector():getRunningScene(), copyteam_atkWithOfflineHelp, 0.1)
end
-- 世界扫荡任务宝箱
function guildarmy_recvReward()
    if(finish_table["guildarmy_recvReward"] == 1)then
        return
    end
    showTip("世界扫荡宝箱")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("世界扫荡宝箱领奖成功")
            finish_table["guildarmy_recvReward"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            require "db/DB_RandArmy_condition_reward"
            local isGet = false
            local info = dictData.ret
            local conf = DB_RandArmy_condition_reward.RandArmy_condition_reward
            local len = table.count(conf)
            local box_task_num = 0
            local box_id = 0
            for i = 1, len do
                local data = DB_RandArmy_condition_reward.getDataById(i)
                if tonumber(data.type) == 2 then
                    box_id = i
                    box_task_num = DB_RandArmy_condition_reward.getDataById(i).condition_number
                    break
                end
            end
            if (box_task_num > #info.reward_info) then
                isGet = true
                showTip("世界扫荡宝箱未开启，无法领取")
                return
            elseif (box_task_num < #info.reward_info) then
                isGet = true
                showTip("世界扫荡宝箱已领取，请勿重复领取")
                finish_table["guildarmy_recvReward"] = 1
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({box_id})
                Network.no_loading_rpc(callback, "guildarmy.recvReward", "guildarmy.recvReward", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "guildarmy.getInfo", "guildarmy.getInfo", nil, true)
end
-- 世界扫荡任务领奖
function guildarmy_oneKeyReward()
    if(finish_table["guildarmy_recvReward"] == 1)then
        return
    end
    showTip("世界扫荡任务领奖")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("世界扫荡任务领奖成功")
            schedule(CCDirector:sharedDirector():getRunningScene(), guildarmy_recvReward, 0.5)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            require "db/DB_RandArmy_condition_reward"
            local isGet = true
            local info = dictData.ret
            local ret = {}
            local conf = DB_RandArmy_condition_reward.RandArmy_condition_reward
            local len = table.count(conf)
            for i = 1, len do
                local data = DB_RandArmy_condition_reward.getDataById(i)
                if tonumber(data.type) == 2 then
                    break
                end
                if tonumber(info.succ_num) >= tonumber(data.condition_number) then
                    local isCollectReward = false
                    for i = 1, #info.reward_info do
                        if tonumber(info.reward_info[i]) == tonumber(data.id) then
                            isCollectReward = true
                            break
                        end
                    end
                    if not isCollectReward == true then
                        ret[#ret + 1] = data.id
                        isGet = false
                    end
                end
            end
            if (isGet) then
                showTip("世界扫荡任务已领取，请勿重复领取")
                schedule(CCDirector:sharedDirector():getRunningScene(), guildarmy_recvReward, 0.5)
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({ret})
                Network.no_loading_rpc(callback, "guildarmy.oneKeyReward", "guildarmy.oneKeyReward", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "guildarmy.getInfo", "guildarmy.getInfo", nil, true)
end

-- 世界扫荡
function guildarmy_attack()
    local _personIndex = 0
    showTip("世界扫荡")
    if not DataCache.getSwitchNodeState(ksSwitchWorldPeople, false) then
        showTip("世界，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("世界扫荡成功")
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local num = 0
            if (not table.isEmpty(info) and not table.isEmpty(info.army)) then
                for k, v in pairs(info.army) do
                    if (not table.isEmpty(v)) then
                        num = num + 1
                    end
                end
            end
            if (num == 0) then
                isGet = true
                showTip("世界扫荡次数用尽，请勿重复攻打")
                schedule(CCDirector:sharedDirector():getRunningScene(), guildarmy_oneKeyReward, 0.5)
                return
            end
            if (table.isEmpty(info.army[1])) then
                -- 按说是不会的 以防抽风
                showTip("世界扫荡程序抽风，已终止扫荡")
                schedule(CCDirector:sharedDirector():getRunningScene(), guildarmy_oneKeyReward, 0.5)
                return
            end
            local attack = function()
                _personIndex = _personIndex + 1
                local p_serverId = info.army[_personIndex].server_id
                local p_pid = info.army[_personIndex].pid
                local args = CCArray:create()
                args:addObject(CCInteger:create(p_serverId))
                args:addObject(CCInteger:create(p_pid))
                -- prints("guildarmy.attack _personIndex " .. _personIndex.."/"..num)
                showTip("世界扫荡" .. _personIndex .. "/" .. num)
                Network.no_loading_rpc(callback, "guildarmy.attack", "guildarmy.attack", args, true)
                if (num == _personIndex) then
                    showTip("世界扫荡完毕")
                    schedule(CCDirector:sharedDirector():getRunningScene(), guildarmy_oneKeyReward, 0.5)
                end
            end
            if (not isGet) then
                schedule(CCDirector:sharedDirector():getRunningScene(), attack, 0.5, num)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "guildarmy.getInfo", "guildarmy.getInfo", nil, true)
end

-- 世界扫荡刷新
function guildarmy_refresh(isConfirm)
    local _personIndex = 0
    showTip("世界扫荡刷新")
    if (isConfirm == false) then
        return
    elseif (isConfirm ~= true) then
        require "script/ui/tip/AlertTip"
        AlertTip.showAlert("是否确认世界刷新", guildarmy_refresh, true, nil)
        return
    end
    if not DataCache.getSwitchNodeState(ksSwitchWorldPeople, false) then
        showTip("世界，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("世界扫荡刷新成功")
            schedule(CCDirector:sharedDirector():getRunningScene(), guildarmy_attack, 0.5)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            -- printT(info)
            -- if(1)then return end
            local stop_num = tonumber(info.stop_num)
            if(stop_num>=20)then
                showTip("今日刷新次数用完")
                return
            end
            local num = 0
            local p_userList = {}
            if (not table.isEmpty(info) and not table.isEmpty(info.army)) then
                for k, v in pairs(info.army) do
                    if (not table.isEmpty(v)) then
                        num = num + 1
                        local tmp = {}
                        table.insert(tmp, v.pid)
                        table.insert(tmp, v.server_id)
                        table.insert(p_userList, tmp)
                    end
                end
            end
            if (num == 0) then
                isGet = true
                showTip("世界扫荡没有敌人")
                return
            end
            if (table.isEmpty(info.army[1])) then
                -- 按说是不会的 以防抽风
                showTip("世界扫荡程序抽风，已终止刷新")
                return
            end
            if(num>20-stop_num)then
                showTip("刷新次数不足，敌人"..num.."个，刷新"..20-stop_num.."个")
                num = 20-stop_num
            else
                showTip("世界扫荡刷新" .. num .. "人")
            end
            local args = Network.argsHandlerOfTable({p_userList})
            Network.no_loading_rpc(callback, "guildarmy.refresh", "guildarmy.refresh", args, true)
        end
    end
    Network.no_loading_rpc(requestFunc, "guildarmy.getInfo", "guildarmy.getInfo", nil, true)
end

-- 军团活跃宝箱
function guild_rewardGuildActive3()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("军团100活跃宝箱领取成功")
            finish_table["guild_rewardGuildActive"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local args = CCArray:create()
    args:addObject(CCInteger:create(3))
    Network.no_loading_rpc(callback, "guild.rewardGuildActive", "guild.rewardGuildActive", args, true)
end
-- 军团活跃宝箱
function guild_rewardGuildActive2()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("军团60活跃宝箱领取成功")
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local args = CCArray:create()
    args:addObject(CCInteger:create(2))
    Network.no_loading_rpc(callback, "guild.rewardGuildActive", "guild.rewardGuildActive", args, true)
end
-- 军团活跃宝箱
function guild_rewardGuildActive1()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("军团40活跃宝箱领取成功")
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local args = CCArray:create()
    args:addObject(CCInteger:create(1))
    Network.no_loading_rpc(callback, "guild.rewardGuildActive", "guild.rewardGuildActive", args, true)
end
-- 军团活跃宝箱
function guild_rewardGuildActive()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("军团活跃宝箱")
    if not DataCache.getSwitchNodeState(ksSwitchGuild, false) then
        showTip("军团，等级未达到")
        return
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet1 = false
            local isGet2 = false
            local isGet3 = false
            local time = 0.2
            local info = dictData.ret
            local my_active = tonumber(info.personal.my_active)
            local my_rewardlist = info.personal.my_rewardlist
            -- prints("my_rewardlist "..#my_rewardlist)
            for i = 1, #my_rewardlist do
                if (1 == tonumber(my_rewardlist[i])) then
                    isGet1 = true
                elseif (2 == tonumber(my_rewardlist[i])) then
                    isGet2 = true
                elseif (3 == tonumber(my_rewardlist[i])) then
                    isGet3 = true
                end
            end
            require "db/DB_Copyact_reward"
            local dbData = DB_Copyact_reward.getDataById(1)
            local retNeedScore = tonumber(dbData.needScore)
            -- prints("retNeedScore1 "..retNeedScore)
            if (my_active < retNeedScore) then
                isGet1 = true
                showTip("活跃度不够，无法开启军团40活跃宝箱")
                return
            else
                if (isGet1) then
                    showTip("军团40活跃宝箱，请勿重复领取")
                else
                    showTip("军团40活跃宝箱领取中")
                    schedule(CCDirector:sharedDirector():getRunningScene(), guild_rewardGuildActive1, time)
                    time = time + 0.2
                end
            end
            dbData = DB_Copyact_reward.getDataById(2)
            retNeedScore = tonumber(dbData.needScore)
            -- prints("retNeedScore2 "..retNeedScore)
            if (my_active < retNeedScore) then
                isGet2 = true
                showTip("活跃度不够，无法开启军团60活跃宝箱")
                return
            else
                if (isGet2) then
                    showTip("军团60活跃宝箱，请勿重复领取")
                else
                    showTip("军团60活跃宝箱领取中")
                    schedule(CCDirector:sharedDirector():getRunningScene(), guild_rewardGuildActive2, time)
                    time = time + 0.2
                end
            end
            dbData = DB_Copyact_reward.getDataById(3)
            retNeedScore = tonumber(dbData.needScore)
            -- prints("retNeedScore3 "..retNeedScore)
            if (my_active < retNeedScore) then
                isGet3 = true
                showTip("活跃度不够，无法开启军团100活跃宝箱")
                return
            else
                if (isGet3) then
                    showTip("军团100活跃宝箱，请勿重复领取")
                    finish_table["guild_rewardGuildActive"] = 1
                else
                    showTip("军团100活跃宝箱领取中")
                    schedule(CCDirector:sharedDirector():getRunningScene(), guild_rewardGuildActive3, time)
                end
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "guild.getGuildActive", "guild.getGuildActive", nil, true)
end

-- 寻龙试炼退出
function dragon_skip()
    showTip("寻龙试炼退出")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("寻龙试炼退出成功")
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local posid = tonumber(info.posid)
            local args = Network.argsHandlerOfTable(posid)
            Network.no_loading_rpc(callback, "dragon.skip", "dragon.skip", args, true)
        end
    end
    Network.no_loading_rpc(requestFunc, "dragon.getMap", "dragon.getMap", nil, true)
end
-- 寻龙试炼攻打试炼一
function dragon_fightBoss()
    showTip("寻龙试炼攻打试炼一")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("寻龙试炼攻打试炼一成功")
            finish_table["dragon_trial"] = 1
            -- 寻龙试炼退出
            -- schedule(CCDirector:sharedDirector():getRunningScene(),dragon_skip,2) -- 存在bug，直接取消掉了，不影响第二天一键扫荡
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local args = Network.argsHandlerOfTable({21000, 0})
    Network.no_loading_rpc(callback, "dragon.fightBoss", "dragon.fightBoss", args, true)
end
-- 寻龙试炼购买行动力一次（2金币）
function dragon_buyAct()
    showTip("寻龙试炼购买行动力一次")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("寻龙试炼购买行动力一次成功")
            schedule(CCDirector:sharedDirector():getRunningScene(), dragon_fightBoss, 0.5)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local args = Network.argsHandlerOfTable({0, 1})
    Network.no_loading_rpc(callback, "dragon.buyAct", "dragon.buyAct", args, true)
end
-- 自动寻龙探宝
function dragon_aiDo()
    showTip("自动寻龙探宝")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("自动寻龙探宝成功")
            schedule(CCDirector:sharedDirector():getRunningScene(), dragon_buyAct, 0.5)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local args = Network.argsHandlerOfTable({5, 3})
    Network.no_loading_rpc(callback, "dragon.aiDo", "dragon.aiDo", args, true)
end
-- 寻龙探宝
function dragon_trial()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("寻龙探宝")
    if not DataCache.getSwitchNodeState(ksFindDragon, false) then
        showTip("寻龙探宝，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("寻龙探宝重置，进入寻龙试炼")
            schedule(CCDirector:sharedDirector():getRunningScene(), dragon_aiDo, 0.5)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local free_reset_num = tonumber(info.free_reset_num)
            if (free_reset_num == 0) then
                isGet = true
                showTip("寻龙探宝无免费重置次数，请勿重复操作")
                finish_table["dragon_trial"] = 1
                return
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "dragon.trial", "dragon.trial", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "dragon.getMap", "dragon.getMap", nil, true)
end
-- 神兽试炼
function magicpetcopy_atkCopy()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("神兽试炼")
    if not DataCache.getSwitchNodeState(ksSwitchMagicPet, false) then
        showTip("神兽试炼，等级未达到")
        return
    end
    require "script/ui/magicpet/copy/MagicPetCopyData"
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("神兽试炼攻打成功")
            MagicPetCopyData.addTodayAtkNum(1)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local open_copy_id = info.open_copy[1]
            require "db/DB_Mythical_copy"
            local free_num = tonumber(DB_Mythical_copy.getDataById(1).challenge_times)
            local buy_atk_num = tonumber(info.buy_atk_num)
            local atk_num = tonumber(info.atk_num)
            local num = free_num - atk_num + buy_atk_num
            if (num <= 0) then
                isGet = true
                showTip("神兽试炼次数用尽，请勿重复操作")
                finish_table["magicpetcopy_atkCopy"] = 1
                return
            end
            local has_attack_num = 0
            local attack = function()
                has_attack_num = has_attack_num + 1
                showTip("神兽试炼攻打" .. has_attack_num .. "/" .. num)
                local args = Network.argsHandlerOfTable({open_copy_id})
                Network.no_loading_rpc(callback, "magicpetcopy.atkCopy", "magicpetcopy.atkCopy", args, true)
            end
            if (not isGet) then
                schedule(CCDirector:sharedDirector():getRunningScene(), attack, 0.2, num)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "magicpetcopy.getInfo", "magicpetcopy.getInfo", nil, true)
end
-- 神兽试炼购买次数
function magicpetcopy_buyAtkNum()
    showTip("神兽试炼购买次数")
    if not DataCache.getSwitchNodeState(ksSwitchMagicPet, false) then
        showTip("神兽试炼，等级未达到")
        return
    end
    require "script/ui/magicpet/copy/MagicPetCopyData"
    local num = tonumber(default_value["magicpetcopy_buyAtkNum"]) or 0 -- 自定义 神兽副本购买次数
    local cost = 0
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("神兽试炼购买次数成功")
            finish_table["magicpetcopy_buyAtkNum"] = 1
            MagicPetCopyData.addBuyTime(num)
            UserModel.addGoldNumber(-cost)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            MagicPetCopyData.setNetInfo(info)
            if(num>MagicPetCopyData.maxBuyTimeConf())then
                num = MagicPetCopyData.maxBuyTimeConf()
            end
            local buy_atk_num = tonumber(info.buy_atk_num)
            if (buy_atk_num >= num) then
                isGet = true
                showTip("神兽试炼次数已购买，请勿重复操作")
                finish_table["magicpetcopy_buyAtkNum"] = 1
                return
            end
            num = num - buy_atk_num
            cost = MagicPetCopyData.getBuyCostByTime(num)
            showTip("神兽试炼购买" .. num .. "次")
            local args = Network.argsHandlerOfTable({num})
            Network.no_loading_rpc(callback, "magicpetcopy.buyAtkNum", "magicpetcopy.buyAtkNum", args, true)
        end
    end
    Network.no_loading_rpc(requestFunc, "magicpetcopy.getInfo", "magicpetcopy.getInfo", nil, true)
end
-- 符印商店天工宝箱
function moon_buyBox()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("天工宝箱")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("天工宝箱领取成功")
            finish_table["moon_buyBox"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local buy_box_count = tonumber(info.buy_box_count)
            if (buy_box_count ~= 0) then
                isGet = true
                showTip("天工宝箱已领取，请勿重复操作")
                finish_table["moon_buyBox"] = 1
                return
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "moon.buyBox", "moon.buyBox", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "moon.getShopInfo", "moon.getShopInfo", nil, true)
end
-- 通天塔购买次数
function godtower_buyNum(set_num,callbackFunc)
    showTip("通天塔购买次数")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("通天塔购买次数成功")
            finish_table["godtower_buyNum"] = 1
            if(callbackFunc~=nil)then
                callbackFunc()
            end
            -- schedule(CCDirector:sharedDirector():getRunningScene(),godtower_search,0.5)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            require "db/DB_Explore_tower"
            local dbInfo = DB_Explore_tower.getDataById(1)
            local free_num = tonumber(dbInfo.free_times)
            local info = dictData.ret
            local num = tonumber(default_value["godtower_buyNum"]) or 1 -- 自定义 购买次数
            local has_used_num = tonumber(info.has_used_num)
            local buy_num = tonumber(info.buy_num)
            if (buy_num >= num and set_num==nil) then
                isGet = true
                showTip("通天塔已购买次数，请勿重复购买")
                finish_table["godtower_buyNum"] = 1
                -- schedule(CCDirector:sharedDirector():getRunningScene(),godtower_search,0.5)
                return
            end
            if(set_num==nil)then
                num = num - buy_num
            else
                num = set_num - (free_num - has_used_num + buy_num)
            end
            if(num<=0)then
                showTip("通天塔购买次数必须大于0")
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({num}) -- 购买次数
                Network.no_loading_rpc(callback, "godtower.buyNum", "godtower.buyNum", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "godtower.getInfo", "godtower.getInfo", nil, true)
end
-- 通天塔
function godtower_search(callbackFunc)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("通天塔")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("通天塔攻打成功")
            schedule(CCDirector:sharedDirector():getRunningScene(), function()godtower_search(callbackFunc)end, 0.5)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            require "db/DB_Explore_tower"
            local dbInfo = DB_Explore_tower.getDataById(1)
            local free_num = tonumber(dbInfo.free_times)
            local has_used_num = tonumber(info.has_used_num)
            local buy_num = tonumber(info.buy_num)
            local floor = tonumber(info.floor)
            local num = free_num - has_used_num + buy_num
            if (num <= 0) then
                isGet = true
                showTip("通天塔已攻打完毕，请勿重复操作")
                finish_table["godtower_search"] = 1
                if(callbackFunc~=nil)then
                    callbackFunc()
                end
                return
            end
            if (not isGet) then
                showTip("通天塔攻打" .. has_used_num + 1 .. "/" .. free_num + buy_num)
                local args = Network.argsHandlerOfTable({floor})
                Network.no_loading_rpc(callback, "godtower.search", "godtower.search", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "godtower.getInfo", "godtower.getInfo", nil, true)
end

-- 精英副本
function ecopy_sweep()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("精英副本")
    if not DataCache.getSwitchNodeState(ksSwitchEliteCopy, false) then
        showTip("精英副本，等级未达到")
        return
    end
    local num = 0
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("精英副本攻打成功")
            finish_table["ecopy_sweep"] = 1
            DataCache.addCanDefatNum(-num)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local can_defeat_num = tonumber(info.can_defeat_num)
            local buy_atk_num = tonumber(info.buy_atk_num)
            num = can_defeat_num + buy_atk_num
            if (num <= 0) then
                isGet = true
                showTip("精英副本已攻打完毕，请勿重复操作")
                finish_table["ecopy_sweep"] = 1
                return
            end
            local atk_copy_id = 0
            for k, v in pairs(info.va_copy_info.progress) do
                if (tonumber(v) == 2) then
                    atk_copy_id = tonumber(k)
                end
            end
            -- prints("atk_copy_id "..atk_copy_id)
            -- prints("num "..num)
            if (atk_copy_id == 0) then
                isGet = true
                showTip("没有可扫荡的精英副本")
                return
            end
            if (not isGet) then
                local args = Network.argsHandlerOfTable({atk_copy_id, num})
                Network.no_loading_rpc(callback, "ecopy.sweep", "ecopy.sweep", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "ecopy.getEliteCopyInfo", "ecopy.getEliteCopyInfo", nil, true)
end

-- 藏书阁寻书
function biography_roll(set_num,callbackFunc)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("藏书阁寻书")
    if not DataCache.getSwitchNodeState(ksSwitchNewBiography, false) then
        showTip("藏书阁，等级未达到")
        return
    end
    local num = 0 -- 本次请求寻书次数
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("藏书阁寻书"..num.."次成功")
            finish_table["biography_roll"] = 1
            if(callbackFunc~=nil)then
                callbackFunc()
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local roll_num = tonumber(info.roll_num)
            local buy_num = default_value["biography_roll"] or 1 -- 设定寻书次数
            -- printT(dictData)
            if (roll_num >= buy_num and set_num == nil) then
                isGet = true
                showTip("藏书阁已寻书，请勿重复操作")
                finish_table["biography_roll"] = 1
                return
            end
            if(set_num~=nil)then
                num = set_num
            else
                num = buy_num - roll_num
            end
            if (not isGet) then
                local args = Network.argsHandler(num) -- 寻书次数
                Network.no_loading_rpc(callback, "biography.roll", "biography.roll", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "biography.getInfo", "biography.getInfo", nil, true)
end

-- 列传副本
function biography_atkCopy()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("列传副本")
    if not DataCache.getSwitchNodeState(ksSwitchNewBiography, false) then
        showTip("列传副本，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            -- printT(dictData)
            local isKill = tonumber(dictData.ret.kill)
            if isKill == 0 then
                showTip("列传副本攻打成功，未击杀，已终止")
                return
            end
            showTip("列传副本攻打成功")
            schedule(CCDirector:sharedDirector():getRunningScene(), biography_atkCopy, 0.5)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local refresh_callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("列传副本刷新成功")
            schedule(CCDirector:sharedDirector():getRunningScene(), biography_atkCopy, 0.5)
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            require "db/DB_Liezhuan_copy"
            require "db/DB_Liezhuan_copyshow"
            local refresh_times = DB_Liezhuan_copy.getDataById(1).refresh_times -- 免费刷新次数
            local challenge_times = DB_Liezhuan_copy.getDataById(1).challenge_times -- 免费攻打次数
            local copyid = tonumber(info.copyid) -- 当前副本id
            local has_refresh_times = tonumber(info.copy_refresh_num) -- 已经刷新次数
            local has_atk_num = tonumber(info.atk_num) -- 已经攻打的次数
            local buy_atk_num = tonumber(info.buy_atk_num) -- 购买的攻打次数
            -- 剩余刷新次数
            local refresh_num = refresh_times - has_refresh_times
            -- 剩余攻击次数
            local atk_num = challenge_times - has_atk_num + buy_atk_num
            -- 副本品质 5紫色 6橙色 7红色
            local quality = tonumber(DB_Liezhuan_copyshow.getDataById(copyid).quality)
            -- 品质低于紫色并且剩余免费刷新次数大于0
            if (quality <= 5 and refresh_num > 0) then
                -- 刷新
                showTip("列传副本免费刷新" .. has_refresh_times + 1 .. "/" .. refresh_times)
                isGet = true
                Network.no_loading_rpc(refresh_callback, "biography.refreshCopy", "biography.refreshCopy", nil, true)
                return
            end
            if (atk_num <= 0) then
                isGet = true
                showTip("列传副本次数用尽，请勿重复操作")
                finish_table["biography_atkCopy"] = 1
                return
            end
            if (not isGet) then
                showTip("列传副本攻打" .. has_atk_num + 1 .. "/" .. challenge_times + buy_atk_num)
                Network.no_loading_rpc(callback, "biography.atkCopy", "biography.atkCopy", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "biography.getInfo", "biography.getInfo", nil, true)
end


local mysteryshopNum = 0
-- 神秘商店刷新
function mysteryshop_playerRfrGoodsList(showDialog)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    -- showTip("神秘商店刷新")
    readDefaultValue(false)
    --printT(default_value["mysteryshop_buy_item_id"])
    require "db/DB_Mystical_goods"
    local goods_list = {}
    local buyItemId = 0
    local price = 0
    local useFree = 0 -- 剩余免费次数
    local useItem = 0 -- 剩余道具次数
    local useGold = 0 -- 剩余金币次数
    local useType = 0 -- 0:免费,1:道具,2:金币
    local _refresh_num = 0
    local Jewel = UserModel.getJewelNum() -- 魂玉数量
    local buy_list = default_value["mysteryshop_buy_item_id"] or {502183,502172} 
    function getRftGoldNum(refresh_num)
        require "db/DB_Mystical_shop"
        local shopData = DB_Mystical_shop.getDataById(1)
        local baseGold = tonumber(shopData.baseGold)
        local growGold= tonumber(shopData.growGold)*(tonumber(refresh_num))
        local costGoldNum= baseGold+growGold
        return costGoldNum
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            mysteryshopNum = mysteryshopNum - 1
            local info = dictData.ret
            if(useType == 1)then--使用道具
                useItem = useItem - 1
            elseif(useType == 2)then--使用金币
                useGold = useGold - 1
                --扣金币
                UserModel.addGoldNumber(-getRftGoldNum(_refresh_num))
            end
            -- printT(info)
            useFree = tonumber(info.sys_refresh_num)
            _refresh_num = tonumber(info.refresh_num)
            -- require "script/model/user/UserModel"
            -- require "db/DB_Vip"
            -- local mysteryShopTimes = DB_Vip.getDataById(tonumber(UserModel.getVipLevel()+1)).mystical_shop_time
            -- useGold = mysteryShopTimes - tonumber(info.refresh_num)
            goods_list = info.goods_list
            showTip("神秘商店刷新成功，剩余刷新次数"..mysteryshopNum)
            --printT(dictData)
            schedule(CCDirector:sharedDirector():getRunningScene(), buyItem, 0.2)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local buy_callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            UserModel.addJewelNum(-price)
            Jewel = Jewel - price
            --prints(buyItemId)
            goods_list[tostring(buyItemId)] = tonumber(goods_list[tostring(buyItemId)]) - 1
            local item_id = string.split(DB_Mystical_goods.getDataById(buyItemId).items,"|")[2] or 0
            if(item_id==0)then
                showTip("获取id失败")
                return
            end
            local name = ItemUtil.getItemById(item_id).name or ""
            showTip("神秘商店"..name.."购买成功")
            schedule(CCDirector:sharedDirector():getRunningScene(), buyItem, 0.2)
        end
    end
    buyItem = function()
        local isGet = false
        buyItemId = 0
        --物品id表
        --502170 属性阵旗碎片包
        --502171 铸造材料包
        --502172 阵旗强化令
        --502173 5星武将包
        --502174 13资质武将包
        --502175 经验金马碎片一
        --502176 经验金书碎片一
        --502177 紫古宝碎片
        --502178 橙古宝碎片
        --502182 红古宝碎片
        --502183 金古宝碎片
        
        for k, v in pairs(goods_list) do
            for m,n in pairs(buy_list) do
                if (tonumber(k) == tonumber(n) and tonumber(v) > 0) then
                    buyItemId = tonumber(k)
                    isGet = true
                    break
                end
            end
        end
        if(isGet)then
            price = tonumber(DB_Mystical_goods.getDataById(buyItemId).costNum)
            if(price>Jewel)then
                showTip("魂玉不足")
                return
            end
            local args = CCArray:create()
            args:addObject(CCInteger:create(buyItemId))
            Network.no_loading_rpc(buy_callback, "mysteryshop.buyGoods", "mysteryshop.buyGoods", args, true)
        else
            local args = CCArray:create()
            if(useFree>0)then
                args:addObject(CCInteger:create(3)) -- 使用系统免费次数刷新
                useType = 0
            elseif(useItem>0)then
                args:addObject(CCInteger:create(2)) -- 使用道具刷新
                useType = 1
            elseif(useGold>0)then
                args:addObject(CCInteger:create(1)) -- 使用金币刷新
                useType = 2
                if(UserModel.getGoldNumber()<getRftGoldNum(_refresh_num))then
                    showTip("金币不足")
                    return
                end
            else
                showTip("神秘商店今日刷新次数全部用完")
                return
            end
            if(mysteryshopNum>0)then
                Network.no_loading_rpc(callback, "mysteryshop.playerRfrGoodsList", "mysteryshop.playerRfrGoodsList",args, true)
            else
                showTip("设定刷新次数使用完毕")
            end
        end
    end
    local confirmBuyItem = function(confirm)
        if(confirm~=true)then
            mysteryshopNum = useFree+useItem
        end
        showTip("设置神秘商店刷新"..mysteryshopNum.."次")
        buyItem()
    end
    local setMysteryShopNum = function(num)
        if(num>useFree+useItem)then
            mysteryshopNum = num
            AlertTip.showAlert("是否使用金币刷新？",confirmBuyItem, true, nil)
        else
            mysteryshopNum = num
            showTip("设置神秘商店刷新"..num.."次")
            buyItem()
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            -- printT(info)
            useFree = tonumber(info.sys_refresh_num)
            _refresh_num = tonumber(info.refresh_num) or 0
            require "script/model/user/UserModel"
            require "db/DB_Vip"
            local mysteryShopTimes = DB_Vip.getDataById(tonumber(UserModel.getVipLevel()+1)).mystical_shop_time
            useGold = mysteryShopTimes - _refresh_num
            useItem = ItemUtil.getCacheItemNumBy(60006) or 0
            goods_list = info.goods_list
            local desc = "购买："
            for k,v in pairs(buy_list) do
                local items = DB_Mystical_goods.getDataById(v).items
                items = "7|" .. string.split(items,"|")[2] .. "|" .. string.split(items,"|")[3]
                desc = desc .. print3TupleNum(string.split(items,","),0)
                if(math.fmod(k,2)==0 and k~=0 and k~=#buy_list)then
                    desc = desc .. "\n           "
                end
            end
            if(showDialog~=false)then
                creteNumSelectUI(setMysteryShopNum,60006,useFree,useGold,useFree,desc)
            else
                setMysteryShopNum(useFree)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "mysteryshop.getShopInfo", "mysteryshop.getShopInfo", nil, true)
end

-- 竞技场挑战
function arena_challenge()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("竞技场挑战")
    local p_num = 0
    if not DataCache.getSwitchNodeState(ksSwitchArena, false) then
        showTip("竞技场，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("竞技场挑战成功")
            UserModel.addStaminaNumber(-2 * p_num)
            finish_table["arena_challenge"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local has_atk_num = tonumber(info.va_active.task["20"]) or 0
            if (info.va_active.task["20"] ~= nil and tonumber(info.va_active.task["20"]) >= 3) then
                isGet = true
                showTip("竞技场已挑战，请勿重复操作")
                finish_table["arena_challenge"] = 1
                return
            end
            local need_atk_num = 3 - has_atk_num
            local info_callback = function(cbFlag, dictData, bRet)
                if (dictData.err == "ok") then
                    local info = dictData.ret
                    if (tonumber(info.res.reward_time) <= 0) then
                        isGet = true
                        showTip("竞技场发奖中，无法攻打")
                        return
                    end
                    local my_pos = tonumber(info.res.position)
                    require "script/ui/arena/ArenaBatchData"
                    local max_num = ArenaBatchData.getFightMaxNum()
                    local position = my_pos + 1
                    local atkedUid = 0
                    for k,v in pairs(info.res.opponents)do
                        if(tonumber(k)>my_pos)then
                            position = tonumber(k)
                            atkedUid = tonumber(v.uid)
                            break
                        end
                    end
                    p_num = max_num
                    if (max_num > need_atk_num) then
                        p_num = need_atk_num
                    end
                    if (p_num > 0) then
                        local args = CCArray:create()
                        args:addObject(CCInteger:create(position)) -- 攻打第几名
                        args:addObject(CCInteger:create(atkedUid)) -- 攻打的人的uid
                        args:addObject(CCInteger:create(p_num)) -- 攻打次数0~50
                        args:addObject(CCInteger:create(1)) -- 是否攻打多次0~1
                        Network.no_loading_rpc(callback, "arena.challenge", "arena.challenge", args, true)
                    else
                        showTip("耐力不足")
                    end
                end
            end
            if (not isGet) then
                Network.no_loading_rpc(info_callback, "arena.getArenaInfo", "arena.getArenaInfo", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "active.getActiveInfo", "active.getActiveInfo", nil, true)
end

local demonboss_button_text = "不使用"
local pUseSavedFormation = nil
function getdemonboss_button_text()
    return demonboss_button_text
end
function getSavedFormation()
    return pUseSavedFormation
end
function initSavedFormation()
    if(pUseSavedFormation~=nil)then
        return
    end
    if(tonumber(CCUserDefault:sharedUserDefault():getIntegerForKey("useFormation"))==1)then
    	pUseSavedFormation=true
        showTip("使用魔王阵容")
    else
        pUseSavedFormation=false
        showTip("不使用魔王阵容")
    end
end
function changeButtonText(isUse)
    if (isUse) then
        demonboss_button_text = "使用"
    else
        demonboss_button_text = "不使用"
    end
end
function setSavedFormation(isUse) -- bool
    pUseSavedFormation = isUse
    changeButtonText(isUse)
end
function useSavedFormation()
    setSavedFormation(true)
    AnimationTip.showTip("使用魔王阵容")
end
function unuseSavedFormation()
    setSavedFormation(false)
    AnimationTip.showTip("不使用魔王阵容")
end

function CanBattleDevilBoss(info)
    require "db/DB_Devil_boss"
    local dbData = DB_Devil_boss.getDataById(1)
    local timeStr = dbData.time
    local timeArray = string.split(timeStr, ",")
    local timeSingleArray = string.split(timeArray[1], "|")

    local serverTime = tonumber(TimeUtil.getSvrTimeByOffset())
    local zeroTime = tonumber(TimeUtil.getCurDayZeroTime(serverTime))
    local bossTime = tonumber(info.boss_time)

    if (bossTime > serverTime and serverTime >= zeroTime + timeSingleArray[2] and serverTime <= zeroTime + timeSingleArray[3]) then
        showTip("魔王cd中,计划" .. bossTime - serverTime .. "s后攻打")
        schedule(CCDirector:sharedDirector():getRunningScene(), demonboss_getDemonBoss, bossTime - serverTime)
        return false
    elseif (serverTime < zeroTime + timeSingleArray[2]) then
        showTip("魔王未开启")
        return false
    elseif (serverTime > zeroTime + timeSingleArray[3]) then
        showTip("魔王已结束")
        return false
    elseif (info.stat == "close") then
        showTip("魔王未开启")
        return false
    else
        return true
    end
end
local atk_DevilBoss_num = 0 -- 剩余攻打次数
local atk_DevilBoss_num1 = 0 -- 本次总攻打次数
local has_atk_DevilBoss_num = 0 -- 累计攻打魔王次数
function atk_demonboss10()
    if (atk_DevilBoss_num ~= 0) then
        showTip("魔王正在攻打，请勿重复点击")
        return
    end
    atk_DevilBoss_num = 10
    atk_DevilBoss_num1 = 10
    demonboss_getDemonBoss()
end
function atk_demonboss15()
    if (atk_DevilBoss_num ~= 0) then
        showTip("魔王正在攻打，请勿重复点击")
        return
    end
    atk_DevilBoss_num = 15
    atk_DevilBoss_num1 = 15
    demonboss_getDemonBoss()
end
function atk_demonboss20()
    if (atk_DevilBoss_num ~= 0) then
        showTip("魔王正在攻打，请勿重复点击")
        return
    end
    atk_DevilBoss_num = 20
    atk_DevilBoss_num1 = 20
    demonboss_getDemonBoss()
end
function atk_demonboss30() -- 累计
    if (atk_DevilBoss_num ~= 0) then
        showTip("魔王正在攻打，请勿重复点击")
        return
    end
    atk_DevilBoss_num = 30
    atk_DevilBoss_num1 = 30
    demonboss_getDemonBoss()
end
function atk_demonboss50() -- 累计
    if (atk_DevilBoss_num ~= 0) then
        showTip("魔王正在攻打，请勿重复点击")
        return
    end
    atk_DevilBoss_num = 50
    atk_DevilBoss_num1 = 50
    demonboss_getDemonBoss()
end

function stop_atk_demonboss()--停止攻打魔王，当出现连续多次失败时，请手动点击停止攻打
    atk_DevilBoss_num = 0
    atk_DevilBoss_num1 = 0
    showTip("停止攻打魔王")
end

function demonboss_getDemonBoss()
    showTip("魔王")
    initSavedFormation()
    if not DataCache.getSwitchNodeState(ksSwitchDevilBoss, false) then
        showTip("魔王，等级未达到")
        atk_DevilBoss_num = 0
        atk_DevilBoss_num1 = 0
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("攻打魔王第" .. has_atk_DevilBoss_num + 1 .. "次成功")
            atk_DevilBoss_num = atk_DevilBoss_num - 1
            if (atk_DevilBoss_num ~= 0) then
                schedule(CCDirector:sharedDirector():getRunningScene(), demonboss_getDemonBoss, 1)
            end
        else
            printT(dictData)
            showTip("攻打魔王第" .. has_atk_DevilBoss_num + 1 .. "次失败")
            schedule(CCDirector:sharedDirector():getRunningScene(), demonboss_getDemonBoss, 1)
            -- showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
            -- atk_DevilBoss_num = 0
            -- atk_DevilBoss_num1 = 0
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            if (not CanBattleDevilBoss(info)) then
                isGet = true
                return
            end
            has_atk_DevilBoss_num = tonumber(info.atk_num)
            if (has_atk_DevilBoss_num >= atk_DevilBoss_num1) then
                showTip("攻打魔王已达到" .. has_atk_DevilBoss_num .. "次，已停止攻打")
                atk_DevilBoss_num = 0
                atk_DevilBoss_num1 = 0
                isGet = true
                return
            end
            -- local atkBoss = function()
            --     showTip("攻打魔王第"..has_atk_DevilBoss_num+1 .."次")
            --     local args = Network.argsHandlerOfTable({tostring(pUseSavedFormation)})--是否使用保存阵容
            --     Network.no_loading_rpc(callback,"team.excute.demonboss.atkBoss","team.excute.demonboss.atkBoss",args,true)
            -- end
            if (not isGet) then
                -- schedule(CCDirector:sharedDirector():getRunningScene(),atkBoss,0.1)
                showTip("攻打魔王第" .. has_atk_DevilBoss_num + 1 .. "次")
                local args = Network.argsHandlerOfTable({tostring(pUseSavedFormation)}) -- 是否使用保存阵容
                Network.no_loading_rpc(callback, "team.excute.demonboss.atkBoss", "team.excute.demonboss.atkBoss", args,true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "demonboss.getDemonBoss", "demonboss.getDemonBoss", nil, true)
end

local addPer = 0 -- 选定好友实际加成值
local pServerId = 0
local pPid = 0
local curType = 0
local pTurnId = 0
local sendType = 0
local occupyTime = 3600 -- 1小时
-- 幻化结缘修炼
function worldplace_occuOther()
    showTip("幻化结缘修炼")
    addPer = 0 -- 选定好友实际加成值
    pServerId = 0
    pPid = 0
    curType = 0
    pTurnId = 0
    sendType = 0
    occupyTime = 3600 -- 1小时
    local serTime = TimeUtil.getSvrTimeByOffset()
    local zeroTime = TimeUtil.getCurDayZeroTime()
    local sixTime = zeroTime + 60 * 60 * 6
    if TimeUtil.getSvrTimeByOffset()<=TimeUtil.getIntervalByTime("060000") then
        showTip("修炼台也要休息，6:00后可进入")
        return
    end
    local add_limit = tonumber(default_value["worldplace_occuOther"]) or 140 -- 结缘修炼额外加成最低值

    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local pData = dictData.ret
            -- 0成功，2已经被占领。3不能站自己的
            if tonumber(pData.code) == 2 then
                showTip("修炼台已被占领")
            elseif tonumber(pData.code) == 3 then
                showTip("不能占领自己的修炼台")
            else
                -- 当延迟启动时，显示有bug，显示+0%，已将addPer调整为全局变量
                showTip("结缘修炼成功，额外加成" .. tostring(addPer) .. "%")
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    require "script/ui/worldplace/WorldPlaceData"
    local putHeroData = WorldPlaceData.getHuanHuaData()[1]
    local dbData = putHeroData.DBInfo
    curType = putHeroData.heroType
    pTurnId = dbData.id
    sendType = 0
    if tonumber(curType) == 3 then
        sendType = WorldPlaceData.getReplSortType(dbData.type)
    elseif tonumber(curType) == 2 then
        sendType = WorldPlaceData.getReplSortType(dbData.type)
    else
        sendType = WorldPlaceData.getHeroSortType(dbData.type, true)
    end
    if (sendType == 0) then
        showTip("幻化修炼参数错误")
        return
    end
    occupiedOther = function()
        if (pServerId == 0 or pPid == 0) then
            showTip("幻化修炼获取id失败")
            return
        end
        local args = Network.argsHandlerOfTable({pTurnId, curType, pServerId, pPid, sendType})
        Network.no_loading_rpc(callback, "worldplace.occuOther", "worldplace.occuOther", args, true)
    end
    occupiedOtherSchedule = function(isConfirm)
        if (isConfirm ~= nil and not isConfirm) then
            showTip("取消结缘修炼")
            return
        end
        if (occupyTime ~= 0) then
            showTip("满足指定加成的结缘修炼台已被占领，计划" .. tostring(occupyTime) .. "s后再次执行")
        end
        schedule(CCDirector:sharedDirector():getRunningScene(), occupiedOther, occupyTime)
    end
    local getRankList = function(info)
        require "script/ui/worldplace/rank/WPlaceRankData"
        local myServerId = UserModel.getServerId()
        local myPid = UserModel.getPid()
        local reData = {}

        for k,v in pairs(info) do
            local curData = v
            local curPid = curData.pid
            local curSid = curData.server_id
            if tonumber(myPid) == tonumber(curPid) and tonumber(myServerId)== tonumber(curSid) then
                --排除自己
            else
                local curPer = WPlaceRankData.getRankPerNum(curData.va_position,curData.va_randoms)
                curData.perNum = curPer
                table.insert(reData,curData)
            end
        end
        table.sort(reData,function(d1,d2)
            return d1.perNum > d2.perNum
        end)
        --只返回最大修炼加成的
        local maxPerNum = 0
        local ret = {}
        for k,v in pairs(reData) do 
            if(v.perNum>maxPerNum)then
                maxPerNum = v.perNum
            end
            if(v.perNum==maxPerNum)then
                table.insert(ret,v)
            end
        end
        return ret,maxPerNum
    end
    local RankList_requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            require "script/ui/worldplace/rank/WPlaceRankData"
            local isMax = true
            local rankList,maxPerNum = getRankList(dictData.ret)
            if(maxPerNum<add_limit)then
                isMax = false
            end
            for k, v in pairs(rankList) do
                -- 额外加成
                local tempaddPer = v.perNum
                local va_friend_position = v.va_friend_position

                -- 好友位置空闲
                if (table.isEmpty(va_friend_position)) then
                    pServerId = v.server_id
                    pPid = v.pid
                    addPer = tempaddPer
                    occupyTime = 0
                    prints("occupiedOther " .. addPer .. "% sid " .. pServerId .. " pid " .. pPid)
                    break
                else
                    -- 好友位置有人,保留时间最短的
                    local nowTime = TimeUtil.getSvrTimeByOffset()
                    if (tonumber(va_friend_position[2]) + 3600 - nowTime <= occupyTime) then
                        occupyTime = tonumber(va_friend_position[2]) + 3600 - nowTime
                        pServerId = v.server_id
                        pPid = v.pid
                        addPer = tempaddPer
                        prints("mintime " .. occupyTime .. " occupiedOther " .. addPer .. "% sid " .. pServerId .." pid " .. pPid)
                    end
                end
            end
            if (not isMax) then
                showTip("没有满足指定加成的结缘修炼台")
                require "script/ui/tip/AlertTip"
                AlertTip.showAlert("当前第一加成" .. tostring(addPer) .. "%,是否选择该修炼台",occupiedOtherSchedule, true, nil)
            else
                occupiedOtherSchedule(true)
            end
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local info = dictData.ret
            local todayOccTime = info.f_occupied_time or 0
            local serTime = TimeUtil.getSvrTimeByOffset()
            local isSame = TimeUtil.isSameDay(serTime, todayOccTime)
            if (not isSame) then
                local args = Network.argsHandlerOfTable({0, 20}) -- 默认拉取第一页数据
                Network.no_loading_rpc(RankList_requestFunc, "worldplace.getRankList", "worldplace.getRankList", args,true)
            else
                showTip("幻化结缘修炼已修炼，请勿重复操作")
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "worldplace.getInfo", "worldplace.getInfo", nil, true)
end


-- 幻化修炼自动上人
function worldplace_getInfo()
    showTip("幻化修炼")
    local serTime = TimeUtil.getSvrTimeByOffset()
    local zeroTime = TimeUtil.getCurDayZeroTime()
    local sixTime = zeroTime + 60 * 60 * 6
    if serTime >= zeroTime and serTime <= sixTime then
        showTip("修炼台也要休息，6:00后可进入")
        return
    end
    require "script/ui/worldplace/WorldPlaceData"
    local huanhuainfo = WorldPlaceData.getHuanHuaData()
    if (table.count(huanhuainfo) == 0) then
        showTip("没有幻化皮肤用于修炼")
        return
    end
    local occupy = function(Pos, TurnId, HeroType)
        local occupy_callback = function(cbFlag, dictData, bRet)
            if dictData.err == "ok" then
                showTip(Pos .. "号位已修炼")
            end
        end
        local args = Network.argsHandlerOfTable({TurnId, Pos, HeroType}) -- 幻化id，修炼位置，幻化类型
        Network.no_loading_rpc(occupy_callback, "worldplace.Occupied", "worldplace.Occupied", args, true)
    end
    local isHaveSpecilTurn = function(Data, TurnId, TurnType)
        for k, v in pairs(Data) do
            if tonumber(v.heroType) == tonumber(TurnType) and tonumber(v.DBInfo.id) == tonumber(TurnId) then
                return true
            end
        end
        return false
    end
    local needPut = function(pos, i)
        for k, v in pairs(pos) do
            if (tonumber(v) == tonumber(i)) then
                return false
            end
        end
        return true
    end
    local getFirstHuanHua = function(hinfo, usedhinfo)
        for k, v in pairs(hinfo) do
            local used = false
            for m, n in pairs(usedhinfo) do
                if tonumber(v.heroType) == tonumber(n[2]) and tonumber(v.DBInfo.id) == tonumber(n[1]) then
                    used = true
                    break
                end
            end
            if (not used) then
                return v.DBInfo.id, v.heroType
            end
        end
        return 0, 0
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local info = dictData.ret
            local usedHuanhua = {}
            local pos = {}
            for a, b in pairs(info.own) do
                table.insert(pos, tonumber(a))
                table.insert(usedHuanhua, {b[1], b[3]})
            end
            for k, v in pairs(info.va_randoms) do
                if (isHaveSpecilTurn(huanhuainfo, v[1], v[2]) and needPut(pos, k)) then
                    showTip(k .. "号位，幸运幻化")
                    occupy(k, v[1], v[2])
                    schedule(CCDirector:sharedDirector():getRunningScene(), worldplace_getInfo, 0.5)
                    table.insert(pos, tonumber(k))
                    table.insert(usedHuanhua, {v[1], v[2]})
                    return
                end
            end
            for i = 1, 6 do
                if (needPut(pos, i)) then
                    local hid, htype = getFirstHuanHua(huanhuainfo, usedHuanhua)
                    if (hid ~= 0) then
                        occupy(i, hid, htype)
                        schedule(CCDirector:sharedDirector():getRunningScene(), worldplace_getInfo, 0.5)
                        return
                    else
                        showTip("幻化数量不够")
                        finish_table["worldplace_getInfo"] = 1
                        return
                    end
                end
            end
            finish_table["worldplace_getInfo"] = 1
            showTip("幻化修炼无空位")
            return
        end
    end
    Network.no_loading_rpc(requestFunc, "worldplace.getInfo", "worldplace.getInfo", nil, true)
end
-- 限时神将招募
function heroshop_getMyShopInfo()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("限时神将免费抽卡")
    if (TimeUtil.getSvrTimeByOffset() < ActiveCache.getHeroShopStartTime() or TimeUtil.getSvrTimeByOffset() >
        ActiveCache.getHeroShopEndTime()) then
        showTip("限时神将抽卡结束")
        return
    end
    require "script/ui/login/ServerList"
    if (ActiveCache.getHeroShopOpenTime() < tonumber(ServerList.getSelectServerInfo().openDateTime)) then
        showTip("限时神将抽卡未开启")
        return
    end
    local dbData = ActiveCache.getCardData()
    local needLevel = dbData.open or 0
    if (UserModel.getHeroLevel() < needLevel) then
        showTip("限时神将抽卡，等级不够")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            showTip("限时神将免费抽卡成功")
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local info = dictData.ret
            local free_cd = tonumber(info.shop_info.free_cd)
            local nowTime = TimeUtil.getSvrTimeByOffset()
            if (nowTime >= free_cd) then
                local args = CCArray:create()
                args:addObject(CCInteger:create(1)) -- 1使用免费次数 2使用金币
                Network.no_loading_rpc(callback, "heroshop.buyHero", "heroshop.buyHero", args, true)
            else
                showTip("限时神将免费抽卡cd中")
                if(TimeUtil.getDifferDay(free_cd)~=0)then
                    finish_table["heroshop_getMyShopInfo"] = 1
                end
            end

        end
    end
    Network.no_loading_rpc(requestFunc, "heroshop.getMyShopInfo", "heroshop.getMyShopInfo", nil, true)
end

function isDoubleTime()
    require "db/DB_Longzhongdui"
    local serverTime = tonumber(TimeUtil.getSvrTimeByOffset())
    local zeroTime = tonumber(TimeUtil.getCurDayZeroTime(serverTime))
    local timeData = DB_Longzhongdui.getDataById(1).doubleTime
    local timeCache = string.split(timeData, ",")
    local timeBegin1 = tonumber(string.split(timeCache[1], "|")[1])
    local timeEnd1 = tonumber(string.split(timeCache[1], "|")[2])
    local timeBegin2 = tonumber(string.split(timeCache[2], "|")[1])
    local timeEnd2 = tonumber(string.split(timeCache[2], "|")[2])
    -- 中午双倍时间12-14点
    if (serverTime >= (zeroTime + timeBegin1) and serverTime < (zeroTime + timeEnd1)) then
        return true
    -- 晚上双倍时间以及之后18-24点
    elseif (serverTime >= (zeroTime + timeBegin2)) then
        return true
    else
        return false
    end
end

-- 隆中对
function lzquiz_getUserInfo()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("隆中对")
    require "db/DB_LongzhongduiQuestion"
    if (not isDoubleTime()) then
        showTip("当前非双倍时间或双倍时间还有一轮")
        return
    end
    local question_num = 0
    -- local reply = nil
    local callback = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local info = dictData.ret
            if (info.rewards == nil) then
                showTip("隆中对第" .. question_num .. "题答题成功")
                question_num = question_num + 1
                schedule(CCDirector:sharedDirector():getRunningScene(), reply, 0.2)
                return
            else
                for k, v in pairs(info.rewards) do
                    if (tonumber(v.type) == 3) then
                        showTip("隆中对第" .. question_num .. "题答题成功\n奖励" .. v.num .. "金币")
                        schedule(CCDirector:sharedDirector():getRunningScene(), lzquiz_getUserInfo, 0.2)
                        return
                    end
                end
                showTip("隆中对答题返回信息处理失败")
                return
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local question = {}
    reply = function()
        if (question_num == 6) then
            showTip("隆中对答题完毕")
            return
        end
        local id = question[question_num] or 0
        if (id == 0) then
            showTip("隆中对数据异常")
            return
        end
        local answer = tonumber(DB_LongzhongduiQuestion.getDataById(id)["true"])
        if (answer == 3) then
            answer = 1
        end
        local args = Network.argsHandlerOfTable({question_num, answer}) -- 第几题（1~5），选择的答案（1~2）
        Network.no_loading_rpc(callback, "lzquiz.commitAnswer", "lzquiz.commitAnswer", args, true)
    end
    local visit_callback = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            schedule(CCDirector:sharedDirector():getRunningScene(), reply, 0.2)
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local isGet = false
            local info = dictData.ret
            local round_no = info.round_no
            if (round_no == nil) then
                isGet = true
                showTip("隆中对答题次数用尽，请勿重复操作")
                finish_table["lzquiz_getUserInfo"] = 1
                return
            end
            question_num = 5 - table.count(info.questions) + 1
            for i = 1, 5 do
                if (info.questions[tostring(i)] ~= nil) then
                    question[i] = tonumber(info.questions[tostring(i)])
                else
                    question[i] = 0
                end
            end
            local visit_time = tonumber(info.visit_time)
            if (visit_time ~= 0) then
                isGet = true
                schedule(CCDirector:sharedDirector():getRunningScene(), reply, 0.2)
                return
            end
            if (not isGet) then
                Network.no_loading_rpc(reply, "lzquiz.visit", "lzquiz.visit", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "lzquiz.getUserInfo", "lzquiz.getUserInfo", nil, true)
end
-- 累积登录
function signactivity_getSignactivityInfo()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("累积登录")

    -- if (TimeUtil.getSvrTimeByOffset() < ActiveCache.getNewYearStartTime() or TimeUtil.getSvrTimeByOffset() >
    --     ActiveCache.getNewYearEndTime()) then
    if(not ActivityConfigUtil.isActivityOpen("signActivity"))then
        showTip("不在累积登录活动时间内")
        finish_table["signactivity_getSignactivityInfo"] = 1
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            showTip("累积登录奖励领取成功")
            finish_table["signactivity_getSignactivityInfo"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local isGet = false
            local info = dictData.ret
            local dayNum = tonumber(info.today)
            local tSignDays = {}
            for i, v in pairs(info.va_acti_sign) do
                tSignDays[tonumber(v)] = tonumber(v)
            end
            if (dayNum > 0 and table.isEmpty(tSignDays)) then
                isGet = false
            end
            if tSignDays[dayNum] == dayNum then
                isGet = true
            end
            if (not isGet) then
                local args = CCArray:create()
                args:addObject(CCInteger:create(dayNum)) -- 领取第几天签到奖励
                Network.no_loading_rpc(callback, "signactivity.gainSignactivityReward",
                    "signactivity.gainSignactivityReward", args, true)
            else
                showTip("累积登录奖励已领取，请勿重复操作")
                finish_table["signactivity_getSignactivityInfo"] = 1
                return
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "signactivity.getSignactivityInfo", "signactivity.getSignactivityInfo", nil,true)
end
-- 欢乐签到
function happysign_gainSignReward()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("欢乐签到")
    require "script/ui/rechargeActive/happySign/HappySignData"
	local currTime = TimeUtil.getSvrTimeByOffset()
	local endTime = HappySignData.getEndTime()
    if (currTime >= endTime) then
        showTip("不在欢乐签到活动时间内")
        finish_table["happysign_gainSignReward"] = 1
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            showTip("欢乐签到奖励领取成功")
            finish_table["happysign_gainSignReward"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local isGet = false
            local info = dictData.ret
            local dayNum = tonumber(info.today)
            local tSignDays = {}
            for i, v in pairs(info.hadSignIdArr) do
                tSignDays[tonumber(v)] = tonumber(v)
            end
            if (dayNum > 0 and table.isEmpty(tSignDays)) then
                isGet = false
            end
            if tSignDays[dayNum] == dayNum then
                isGet = true
            end
            if (not isGet) then
                --local args = Network.argsHandlerOfTable({id,selectID})-- 天数,选择签到的天数
                local args = Network.argsHandlerOfTable({dayNum})-- 天数,选择签到的天数
                Network.no_loading_rpc(callback, "happysign.gainSignReward", "happysign.gainSignReward", args, true)
            else
                showTip("欢乐签到奖励已领取，请勿重复操作")
                finish_table["happysign_gainSignReward"] = 1
                return
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "happysign.getSignInfo", "happysign.getSignInfo", nil, true)
end
-- 放三令牌副本自动攻打
function warorder_getInfo()
    showTip("放三令牌")
    if (not ActivityConfigUtil.isActivityOpen("warOrder")) then
        showTip("放三令牌未开启")
        finish_table["warorder_getInfo"] = 1
        return
    end
    local getAttackedMaxIndex = function(_info)
        local index = 0
        for k, v in pairs(_info.copy) do
            if tonumber(v) > index then
                index = tonumber(v)
            end
        end
        return index
    end
    local getCurCopyIndex = function(_info)
        require "script/ui/warorder/copy/WarorderCopyData"
        -- 已攻打过最大index
        local index = getAttackedMaxIndex(_info)
        index = index + 1

        -- 最大部队数
        local maxIndex = WarorderCopyData.getAcopyArmyNum()
        if index > maxIndex then
            index = maxIndex
        end
        return index
    end
    local callback = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            showTip("放三令牌副本攻打成功")
            finish_table["warorder_getInfo"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local isGet = false
            local info = dictData.ret
            local curTime = TimeUtil.getSvrTimeByOffset()
            if (TimeUtil.isSameDay(curTime, tonumber(info.last_fight_time))) then
                isGet = true
                showTip("放三令牌副本今日已攻打，请勿重复操作")
                finish_table["warorder_getInfo"] = 1
                return
            end
            local pIndex = getCurCopyIndex(info)
            if (not isGet) then
                local args = Network.argsHandlerOfTable({pIndex}) -- 第几个副本
                Network.no_loading_rpc(callback, "warorder.atkCopy", "warorder.atkCopy", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "warorder.getInfo", "warorder.getInfo", nil, true)
end
-- 好友耐力领取
function friend_unreceiveLoveList()
    showTip("好友耐力领取")
    require "db/DB_Give_stamina"
    local hasReceivedNum = 0
    local callback = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local curUseTimes = tonumber(dictData.ret.receivedNum)
            -- 获得的耐力
            local oneData = tonumber(DB_Give_stamina.getDataById(1).give_stamina_num) or 0
            local totalData = oneData * curUseTimes
            local totalNum = tonumber(DB_Give_stamina.getDataById(1).get_stamina_times) or 30
            UserModel.addStaminaNumber(totalData)
            showTip("好友耐力领取成功，领取" .. totalData .. "次，剩余" .. totalNum - hasReceivedNum - curUseTimes .. "次")
            if (totalNum - hasReceivedNum - curUseTimes == 0) then
                finish_table["friend_unreceiveLoveList"] = 1
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local isGet = false
            local info = dictData.ret
            hasReceivedNum = tonumber(info.num)
            local times = 0
            local totalNum = tonumber(DB_Give_stamina.getDataById(1).get_stamina_times) or 30
            if (totalNum - hasReceivedNum <= 0) then
                isGet = true
                showTip("好友耐力已领取，请勿重复操作")
                finish_table["friend_unreceiveLoveList"] = 1
                return
            end
            -- 耐力已达上限
            if (UserModel.getStaminaNumber() >= UserModel.getMaxStaminaNumber()) then
                isGet = true
                showTip("耐力已达上限，无法领取")
                return
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "friend.receiveAllLove", "friend.receiveAllLove", nil, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "friend.unreceiveLoveList", "friend.unreceiveLoveList", nil, true)
end
--是否在吃烧鸡时间段
function isSupplyTime()
    local isOpen = false
    if (ActiveCache.isOnAfternoon(TimeUtil.getSvrTimeByOffset())) then
        isOpen = true
    -- elseif(not ActiveCache.isPassTime(_lastReceiveTime,155900) and ActiveCache.isOnNight(TimeUtil.getSvrTimeByOffset())) then
    -- 	isGet = false
    elseif (ActiveCache.isOnEvening(TimeUtil.getSvrTimeByOffset())) then
        isOpen = true
    elseif (ActiveCache.isOnNight(TimeUtil.getSvrTimeByOffset())) then
        isOpen = true
    end
    return isOpen
end
-- 吃烧鸡
function supply_getSupplyInfo()
    showTip("吃烧鸡")
    if(not isSupplyTime())then
        showTip("当前时间段吃烧鸡未开启")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            if ActiveCache.isChickenActiveOpen() then
                UserModel.addEnergyValue(50)
                UserModel.addGoldNumber(50)
                AnimationTip.showTip("吃烧鸡成功,获得50体力和50金币")
            else
                UserModel.addEnergyValue(tonumber(dictData.ret))
                AnimationTip.showTip("吃烧鸡成功,获得" .. dictData.ret .. "体力")
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    -- 获得获得上次领取的时间
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = true
            local _lastReceiveTime = tonumber(dictData.ret)
            -- 判断是否可以在 领取时间段内：12~14， 16~18
            if (not ActiveCache.isPassTime(_lastReceiveTime, 115900) and
                ActiveCache.isOnAfternoon(TimeUtil.getSvrTimeByOffset())) then
                isGet = false
                -- elseif(not ActiveCache.isPassTime(_lastReceiveTime,155900) and ActiveCache.isOnNight(TimeUtil.getSvrTimeByOffset())) then
                -- 	isGet = false
            elseif (not ActiveCache.isPassTime(_lastReceiveTime, 175900) and
                ActiveCache.isOnEvening(TimeUtil.getSvrTimeByOffset())) then
                isGet = false
            elseif (not ActiveCache.isPassTime(_lastReceiveTime, 205900) and
                ActiveCache.isOnNight(TimeUtil.getSvrTimeByOffset())) then
                isGet = false
            end
            if (not isGet) then
                Network.no_loading_rpc(callback, "supply.supplyExecution", "supply.supplyExecution", nil, true)
            else
                showTip("当前时间段烧鸡已吃或吃烧鸡未开启")
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "supply.getSupplyInfo", "supply.getSupplyInfo", nil, true)
end
-- 吃蛋糕
function timelimitsign_reward()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("吃蛋糕")
    require "script/ui/anniver/AnniverDef"
    if(not ActivityConfigUtil.isActivityOpen("timelimitsign"))then
        showTip("吃蛋糕活动未开启")
        finish_table["timelimitsign_reward"] = 1
        return
    end
    local getCurTime = function()
        local temp = os.date("*t", TimeUtil.getSvrTimeByOffset())
        local ret = temp.hour*3600 + temp.min*60 + temp.sec
        return ret
    end
    local getRewardTimeById = function(pId)
        local timeLimit = ActivityConfigUtil.getDataByKey("timelimitsign").data[tonumber(pId)].reward_times
        timeLimit = string.split(timeLimit,"|")
        local startTime = tonumber(timeLimit[1])
        local endTime   = tonumber(timeLimit[2])
        return startTime, endTime
    end
    local isAlreadyRecievedById = function(info,pId)
        for i,v in pairs(info) do
            if tonumber(pId) == tonumber(v) then
                return true
            end
        end
        return false
    end
    local getRecieveStatu = function(info,pId)
        if isAlreadyRecievedById(info,pId) then
            return AnniverDef.ALREADY_RECIEVED
        end
        local startTime = nil
        local endTime = nil
        startTime, endTime = getRewardTimeById(pId)
        local curTime = getCurTime()
        if curTime > endTime then
            return AnniverDef.OUT_OF_DATE
        elseif curTime < startTime then
            return AnniverDef.NOT_TIME_YET
        else
            return AnniverDef.CAN_RECIEVE_NOW
        end
    end
    local curTime = getCurTime()
    local firstStart,firstEnd = getRewardTimeById(1)
    if(firstStart>curTime)then
        showTip("第一个蛋糕未开启")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            AnimationTip.showTip("吃蛋糕成功")
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    -- 获得获得上次领取的时间
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = true
            local info = dictData.ret
            local pId = 0
            for i=1,4 do
                local isCanRecieve = getRecieveStatu(info,i)
                if(isCanRecieve == AnniverDef.CAN_RECIEVE_NOW) then
                    isGet = false
                    pId = i
                    break
                end
            end
            if(pId==0)then
                isGet = true
                showTip("吃蛋糕获取id失败或蛋糕已吃")
                return
            end
            if (not isGet) then
                local args = CCArray:create()
                args:addObject(CCInteger:create(pId))
                Network.no_loading_rpc(callback, "timelimitsign.reward", "timelimitsign.reward", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "timelimitsign.getInfo", "timelimitsign.getInfo", nil, true)
end

-- 积分轮盘
function roulette_rollRoulette()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("积分轮盘")
    require "script/model/utils/ActivityConfig"
    local startTime = ActivityConfigUtil.getDataByKey("roulette").start_time
    local wheelDay = ActivityConfigUtil.getDataByKey("roulette").data[1].wheelopentime -- 配置为聚宝期的天数
    if (wheelDay ~= nil) then
        -- local curTime = TimeUtil.getSvrTimeByOffset()
        if (TimeUtil.getDifferDay(startTime) >= tonumber(wheelDay)) then
            showTip("当前不在积分轮盘活动期间")
            finish_table["roulette_rollRoulette"] = 1
            return
        elseif(TimeUtil.getDifferDay(startTime) < 0 )then
            showTip("当前不在积分轮盘活动期间")
            finish_table["roulette_rollRoulette"] = 1
            return
        end
    end
    local callback = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            showTip("积分轮盘抽奖成功")
            finish_table["roulette_rollRoulette"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local isGet = false
            local info = dictData.ret
            require "db/DB_Vip"
            local vip = tonumber(UserModel.getVipLevel())
            local totalFreemNum = tonumber(DB_Vip.getDataById(vip + 1).FreeTimes)
            local alreadyFreeNum = tonumber(info.today_free_num)
            local havaFreeNum = totalFreemNum - alreadyFreeNum
            if (havaFreeNum <= 0) then
                isGet = true
                showTip("积分轮盘次数用完，请勿重复操作")
                finish_table["roulette_rollRoulette"] = 1
                return
            end
            if (not isGet) then
                local args = CCArray:create()
                args:addObject(CCInteger:create(havaFreeNum))
                Network.no_loading_rpc(callback, "roulette.rollRoulette", "roulette.rollRoulette", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "roulette.getMyRouletteInfo", "roulette.getMyRouletteInfo", nil, true)
end

-- 节日盛典
function annivseven_recvTaskReward()
    showTip("节日盛典")
    local startTime = ActivityConfigUtil.getDataByKey("annivSevenTask").start_time
    local endTime = ActivityConfigUtil.getDataByKey("annivSevenTask").end_time
    local curTime = TimeUtil.getSvrTimeByOffset()
    if (startTime>=curTime or curTime>=endTime) then
        showTip("当前不在积分轮盘活动期间")
        finish_table["annivseven_recvTaskReward"] = 1
        return
    end
    local isFinishCard = function( info,pId )
        if table.isEmpty(info) or table.isEmpty(info.cardInfo) then
            return false
        end
        local time = tonumber(info.cardInfo[""..pId]) or 0
        if time == 0 or time < TimeUtil.getSvrTimeByOffset() then
            return false
        end
        return true
    end
    local dealNetTodo = function(info)
        local curConf =  ActivityConfigUtil.getDataByKey("annivSevenTask").data
        local todayId = nil -- 今天是对应第*天奖励id
        local littleMonthId = nil --小月卡
        local bigMonthId = nil -- 大月卡
        local consume = nil --消费100金
        local charge = nil --充值
        local tmp = {}
        for k,v in pairs(curConf)do
            local curTaskType = tonumber(v.task_type)
            local curId = tonumber(v.id)
            if  curTaskType == 11 then
                --是登陆第*天奖励
                local today = TimeUtil.getDifferDay(ActivityConfigUtil.getDataByKey("annivSeven").start_time) + 1
                if today == tonumber(v.finish) then
                    tmp[curId] = 1
                end
            elseif  curTaskType == 12 then 
                --月卡
    
                if isFinishCard(info,v.finish) then
                    tmp[curId] = 1
                end
            elseif  curTaskType == 13 then 
                --花金币
                if tonumber(info.cost) > 0 then
                    tmp[curId] = math.floor(tonumber(info.cost) /tonumber(v.finish) )
                end
            elseif  curTaskType == 14 then 
                --充值
                if tonumber(info.recharge) >= tonumber(v.finish) then
                    tmp[curId] = 1
                end
            end
        end
        if info.task.done then
            for k,v in pairs(info.task.done) do
                k = tonumber(k)
                if tmp[k] then
                    tmp[k] = tonumber(tmp[k]) - tonumber(v)
                    if tmp[k] <= 0 then
                        tmp[k] = nil
                    end
                end
            end
        end
        return tmp
    end

    local callback = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            showTip("节日盛典签到成功")
            finish_table["annivseven_recvTaskReward"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local isGet = false
            local info = dictData.ret
            local todo = dealNetTodo(info)
            --printT(todo)
            if(table.isEmpty(todo))then
                isGet = true
                showTip("节日盛典已签到，请勿重复操作")
                finish_table["annivseven_recvTaskReward"] = 1
                return
            end
            if (not isGet) then
                local dic = CCDictionary:create()
                for i,v in pairs (todo) do
                    dic:setObject(CCInteger:create(v),i)
                end
                local args = Network.argsHandlerOfTable({dic})
                Network.no_loading_rpc(callback, "annivseven.recvTaskReward", "annivseven.recvTaskReward", args, true)
            end
        end
    end
    local index = 1
    Network.rpc(requestFunc, "annivseven.getInfo"..index, "annivseven.getInfo", nil, true)
end

-- 副本基金
function copyfund_gainReward()
    showTip("副本基金")
    if isBagFull(true) then
        showTip("背包满了")
        return
  	end
    if(not ActivityConfigUtil.isActivityOpen("copyFund"))then
        showTip("当前不在副本基金活动期间")
        finish_table["copyfund_gainReward"] = 1
        return
    end
    local isHaveRewardBy = function(info, pId, pType)
        local retData = false
        local rewardInfo = info.reward or {}
        for k, v in pairs(rewardInfo[tostring(pType)] or {}) do
            if tonumber(v) == tonumber(pId) then
                retData = true
                break
            end
        end
        return retData
    end

    local getListData = function(info)
        local retData = {}
        local retData1 = {} --已领取的
        local dbData = ActivityConfigUtil.getDataByKey("copyFund").data
        for k,v in ipairs(dbData) do
            --免费和付费的都领取了放后边
            local isHave1 = isHaveRewardBy(info, v.id, 1)
            local isHave2 = isHaveRewardBy(info, v.id, 2)
            local isHave3 = isHaveRewardBy(info, v.id, 3)
            if isHave1 and isHave2 and isHave3 then
                table.insert(retData1,v)
            else
                table.insert(retData,v)
            end
        end
        table.sort( retData, function ( data1, data2 )
            return tonumber(data1.id) < tonumber(data2.id)
        end )
        table.sort( retData1, function ( data1, data2 )
            return tonumber(data1.id) < tonumber(data2.id)
        end )
    
        for i,v in ipairs(retData1) do
            table.insert(retData,v)
        end
        return retData
    end

    local isCanRewardBy = function(info, pId, pType)
        local dbData = ActivityConfigUtil.getDataByKey("copyFund").data[tonumber(pId)]
        --星数不足
        local needLevel = tonumber(dbData.copy_star) or 0
        if needLevel > DataCache.getSumCopyStar() then
            return false
        end
        --已领取
        local isHave = isHaveRewardBy(info, pId, pType)
        if isHave then
            return false
        end
        --如果是付费 充值不够
        local chargeNum = tonumber(info.charge_gold) or 0
        local needTab = string.split(dbData.rechargelimit,"|")
        if tonumber(needTab[tonumber(pType)]) > chargeNum then
            return false
        end
        return true
    end

    local getCanRewardData = function(info)
        local retData = {}
        retData["1"] = {} --免费
        retData["2"] = {} --付费
        retData["3"] = {} --付费
        local listData = getListData(info)
        for k,v in pairs(listData) do
            local isCan = isCanRewardBy(info,v.id,1)
            if isCan then
                table.insert(retData["1"],v.id)
            end
            local isCan2 = isCanRewardBy(info,v.id,2)
            if isCan2 then
                table.insert(retData["2"],v.id)
            end
            local isCan3 = isCanRewardBy(info,v.id,3)
            if isCan3 then
                table.insert(retData["3"],v.id)
            end
        end
        return retData
    end
    --获取任务数量，用来判断奖励是否全部领取
    local getRewardNum = function()
        local data = ActivityConfigUtil.getDataByKey("copyFund").data
        local num = 0
        for k,v in pairs(data) do 
            num = num + 1
        end
        return num
    end

    local callback = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            showTip("副本基金领取成功，获得金币"..addGold)
            finish_table["limittimegift_gainReward"] = 1
            if(addGold>0)then
                UserModel.addGoldNumber(addGold)
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local isGet = false
            local info = dictData.ret
            if(#info.reward["1"] == getRewardNum())then
                isGet = true
                showTip("副本基金已领取完毕，请勿重复操作")
                finish_table["copyfund_gainReward"] = 1
                return
            end
            local canArr = getCanRewardData(info)
            local canArgs = canArr[tostring(1)]
            if table.isEmpty(canArgs) then
                isGet = true
                showTip("副本基金当前无可领取物品")
                return
            end
            local arg = {}
            arg[tostring(1)] = canArgs
            if (not isGet) then
                local rewardDic = CCDictionary:create()
                for k,v in pairs(arg) do
                    local array = CCArray:create()
                    for i,lv in ipairs(v) do
                        array:addObject(CCInteger:create(lv))
                    end
                    rewardDic:setObject(array, tostring(k))
                end
                local args = CCArray:create()
                args:addObject(rewardDic)
                Network.no_loading_rpc(callback, "copyfund.gainReward", "copyfund.gainReward", args, true)
            end
        end
    end
    rpcCountIndex = rpcCountIndex +1
    Network.no_loading_rpc(requestFunc, "copyfund.getInfo"..rpcCountIndex, "copyfund.getInfo", nil, true)
end

-- 财神
function getrich_buy()
    showTip("迎财神")
    if(not ActivityConfigUtil.isActivityOpen("getrich"))then
        showTip("迎财神活动未开启")
        finish_table["getrich_buy"] = 1
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local info = dictData.ret
            showTip("迎财神成功,获得金币"..info.getGold)
            UserModel.addGoldNumber(tonumber(info.getGold))
            schedule(CCDirector:sharedDirector():getRunningScene(), getrich_buy, 0.2)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local isGet = false
            local info = dictData.ret
            local haveGot = tonumber(info.maxHasGet) or 0
            local activeInfo = ActivityConfigUtil.getDataByKey("getrich").data
            if(activeInfo[haveGot + 1] == nil)then
                isGet = true
                showTip("迎财神全部次数用完，请勿重复操作")
                finish_table["getrich_buy"] = 1
                return
            end
            local curActiveInfo = activeInfo[haveGot + 1]
            local needCharge = 0
            if(tonumber(curActiveInfo.recharge) == 1)then
                needCharge =  tonumber(curActiveInfo.recharge_gold)
            end
            if(tonumber(info.hasRecharge) < needCharge)then
                isGet = true
                showTip("迎财神次数用完，增加次数需要充值")
                finish_table["getrich_buy"] = 1
                return
            end
            local curHaveGod = UserModel.getGoldNumber()
            if(curHaveGod < tonumber(curActiveInfo.spend))then
                isGet = true
                showTip("迎财神金币不足")
                return
            end
            if (not isGet) then
                local args = CCArray:create()
                args:addObject(CCInteger:create(haveGot + 1))
                Network.no_loading_rpc(callback, "getrich.buy", "getrich.buy", args, true)
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "getrich.getInfo", "getrich.getInfo", nil, true)
end

-- 成长基金
function limittimegift_gainReward()
    showTip("成长基金")
    if isBagFull(true) then
        showTip("背包满了")
        return
  	end
    local addGold = 0
    require "db/DB_Limittime_gift"
    local isHaveRewardBy = function(info, pId, pType)
        local retData = false
        local rewardInfo = info.reward or {}
        for k, v in pairs(rewardInfo[tostring(pType)] or {}) do
            if tonumber(v) == tonumber(pId) then
                retData = true
                break
            end
        end
        return retData
    end

    local getListData = function(info)
        local retData = {}
        local retData1 = {} --已领取的
        for k,v in dbpairs(DB_Limittime_gift) do
            --免费和付费的都领取了放后边
            local isHave1 = isHaveRewardBy(info, v.id, 1)
            local isHave2 = isHaveRewardBy(info, v.id, 2)
            if isHave1 and isHave2 then
                table.insert(retData1,v)
            else
                table.insert(retData,v)
            end
        end
        table.sort( retData, function ( data1, data2 )
            return tonumber(data1.id) < tonumber(data2.id)
        end )
        table.sort( retData1, function ( data1, data2 )
            return tonumber(data1.id) < tonumber(data2.id)
        end )
        for i,v in ipairs(retData1) do
            table.insert(retData,v)
        end
        return retData
    end

    local isCanRewardBy = function(info, pId, pType)
        local dbData = DB_Limittime_gift.getDataById(pId)
        --等级不足
        local needLevel = tonumber(dbData.open_level) or 0
        if needLevel > UserModel.getHeroLevel() then
            return false
        end
        --已领取
        local isHave = isHaveRewardBy(info, pId, pType)
        if isHave then
            return false
        end
        --如果是付费 充值不够
        local chargeNum = tonumber(info.charge_gold) or 0
        if tonumber(pType) == 2 and tonumber(dbData.addGold) > chargeNum then
            return false
        end
        return true
    end

    local getCanRewardData = function(info)
        local retData = {}
        retData["1"] = {} --免费
        retData["2"] = {} --付费
        local listData = getListData(info)
        for k,v in pairs(listData) do
            local isCan = isCanRewardBy(info,v.id,1)
            if isCan then
                table.insert(retData["1"],v.id)
            end
            local isCan2 = isCanRewardBy(info,v.id,2)
            if isCan2 then
                table.insert(retData["2"],v.id)
            end
        end
        return retData
    end
    --获取任务数量，用来判断奖励是否全部领取
    local getRewardNum = function()
        local num = 0
        for k,v in dbpairs(DB_Limittime_gift) do
            num = num + 1
        end
        return num
    end
    local getGoldNum = function(id_list)
        local num = 0
        for k,v in dbpairs(DB_Limittime_gift) do
            for m,n in pairs(id_list) do
                if(tonumber(v.id) == tonumber(n))then
                    local addGold = tonumber(string.split(v.free,"|")[3])
                    num = num + addGold
                end
            end
        end
        return num
    end
    local callback = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            showTip("成长基金领取成功，获得金币"..addGold)
            finish_table["limittimegift_gainReward"] = 1
            if(addGold>0)then
                UserModel.addGoldNumber(addGold)
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local isGet = false
            local info = dictData.ret
            if(#info.reward["1"] == getRewardNum())then
                isGet = true
                showTip("成长基金已领取完毕，请勿重复操作")
                finish_table["limittimegift_gainReward"] = 1
                return
            end
            local canArr = getCanRewardData(info)
            local canArgs = canArr[tostring(1)]
            if table.isEmpty(canArgs) then
                isGet = true
                showTip("成长基金当前无可领取物品")
                return
            end
            addGold = getGoldNum(canArgs)
            local arg = {}
            arg[tostring(1)] = canArgs
            if (not isGet) then
                local rewardDic = CCDictionary:create()
                for k,v in pairs(arg) do
                    local array = CCArray:create()
                    for i,lv in ipairs(v) do
                        array:addObject(CCInteger:create(lv))
                    end
                    rewardDic:setObject(array, tostring(k))
                end
                local args = CCArray:create()
                args:addObject(rewardDic)
                Network.no_loading_rpc(callback, "limittimegift.gainReward", "limittimegift.gainReward", args, true)
            end
        end
    end
    rpcCountIndex = rpcCountIndex +1
    Network.no_loading_rpc(requestFunc, "limittimegift.getInfo"..rpcCountIndex, "limittimegift.getInfo", nil, true)
end

-- 星魂副本扫荡
function gcopy_sweep()
    showTip("星魂副本扫荡")
    if not DataCache.getSwitchNodeState(ksSwitchGoldCopy, false) then
        showTip("星魂副本，等级未达到")
        return
    end
    require "db/DB_Normal_config"
    local norCfg = DB_Normal_config.getDataById(1)
    local openLevel = tonumber(norCfg.soul_quickpass)
    local userLevel = UserModel.getHeroLevel()
    if userLevel < openLevel  then
        showTip("星魂副本一键扫荡，等级未达到")
        return 
    end
    local function getSaveKey()
        require "script/ui/login/ServerList"
        require "script/platform/Platform"
        local pid = Platform.getPid()
        local serverId = ServerList.getSelectServerInfo().group
        local saveKey = string.format("[%s][%s][GCopySweep]", serverId, pid)
        return saveKey
    end
    local function loadSelectBaseIds()
        local saveKey = getSaveKey()
        local loadStr = CCUserDefault:sharedUserDefault():getStringForKey(saveKey)
        local selectIds = {}
        if string.len(loadStr) > 2 then
            selectIds = table.unserialize(loadStr)
        end
        return selectIds
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("星魂副本扫荡成功")
            finish_table["gcopy_sweep"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = true
            local info = dictData.ret
            require "db/DB_Betterhero_copy"
            local atk_info = {}
            for k,v in pairs(info)do
                k=tonumber(k)
                atk_info[k]={}
                local config = DB_Betterhero_copy.getDataById(k)
                local norlNum = tonumber(config.num)
                local finish_num = tonumber(v.finish_num)
                local hasbuy_num = tonumber(v.hasbuy_num)
                local num = norlNum + hasbuy_num - finish_num
                atk_info[k].num = num
                if(num>0)then
                    isGet = false
                end
            end
            local selectBaseIdArr = loadSelectBaseIds()
            if(table.isEmpty(selectBaseIdArr))then
                showTip("从缓存中获取id失败，使用默认配置")
                local BaseIdArr = {
                    [1]  = {["魏"]=460004,["蜀"]=460002,["吴"]=460003,["群"]=460001},  --460004 蔡文姬,  460002 黄月英,  460003 小乔,      460001 华佗,
                    [2]  = {["魏"]=460006,["蜀"]=460005,["吴"]=460008,["群"]=460007},  --460006 张辽,    460005 诸葛亮,  460008 孙策,      460007 左慈,
                    [3]  = {["魏"]=460009,["蜀"]=460010,["吴"]=460011,["群"]=460012},  --460009 郭嘉,    460010 张飞,    460011 陆逊,      460012 贾诩,
                    [4]  = {["魏"]=460013,["蜀"]=460014,["吴"]=460015,["群"]=460016},  --460013 夏侯渊,  460014 关羽,    460015 文鸯,      460016 于吉,
                    [5]  = {["魏"]=460017,["蜀"]=460018,["吴"]=460019,["群"]=460020},  --460017 庞德,    460018 庞统,    460019 水镜先生,  460020 南华老仙,
                    [6]  = {["魏"]=460021,["蜀"]=460022,["吴"]=460023,["群"]=460024},  --460021 荀彧,    460022 马良,    460023 朱桓,      460024 张仲景,
                    [7]  = {["魏"]=460025,["蜀"]=460026,["吴"]=460027,["群"]=460028},  --460025 张郃,    460026 马超,    460027 孙尚香,    460028 貂蝉,
                    [8]  = {["魏"]=460029,["蜀"]=460030,["吴"]=460031,["群"]=460032},  --460029 司马懿,  460030 赵云,    460031 周瑜,      460032 吕布,
                    [9]  = {["魏"]=460033,["蜀"]=460034,["吴"]=460035,["群"]=460036},  --460033 曹操,    460034 刘备,    460035 孙权,      460036 董卓,
                    [10] = {["魏"]=460037,["蜀"]=460038,["吴"]=460039,["群"]=460040},  --460037 甄姬,    460038 黄忠,    460039 太史慈,    460040 张角,
                }
                if(table.isEmpty(default_value["gcopy_sweep"]))then
                    readDefaultValue()
                end
                for k,v in pairs(default_value["gcopy_sweep"])do
                    if(k=="主限")then
                        selectBaseIdArr[8] = BaseIdArr[8][v]
                    elseif(k=="副限")then
                        selectBaseIdArr[2] = BaseIdArr[2][v]
                    elseif(k=="充值")then
                        selectBaseIdArr[5] = BaseIdArr[5][v]
                    elseif(k=="热卖")then
                        selectBaseIdArr[4] = BaseIdArr[4][v]
                        selectBaseIdArr[6] = BaseIdArr[6][v]
                    elseif(k=="酒馆")then
                        selectBaseIdArr[1] = BaseIdArr[1][v]
                        selectBaseIdArr[3] = BaseIdArr[3][v]
                        selectBaseIdArr[7] = BaseIdArr[7][v]
                        selectBaseIdArr[9] = BaseIdArr[9][v]
                        selectBaseIdArr[10] = BaseIdArr[10][v]
                    else
                        showTip("星魂副本设置出现错误类别")
                    end
                end
            end
            for k,v in pairs(selectBaseIdArr)do
                k=tonumber(k)
                atk_info[k].select_copy = tonumber(v)
            end
            --printT(atk_info)

            --if(1)then return end
            if (not isGet) then
                local args = CCArray:create()
                local dict = CCDictionary:create()
                for k,v in pairs(atk_info) do
                    dict:setObject(CCInteger:create(v.select_copy), k)
                end
                args:addObject(dict)
                Network.no_loading_rpc(callback, "gcopy.sweep","gcopy.sweep", args, true)
            else
                showTip("星魂副本，请勿重复攻打")
                finish_table["gcopy_sweep"] = 1
                return
            end
        end
    end
    Network.no_loading_rpc(requestFunc, "gcopy.getAllCopyInfo", "gcopy.getAllCopyInfo", nil, true)
end

local RobTreasureNum = 0
local SetRobTreasureNum = 3
--一键夺宝
function oneKeySeize1(pTreasureId, pIfUse, pCostItemArr, pReqeustNum, pCallback)
	local requestFunc = function( cbFlag, dictData, bRet )
		if(bRet == true) then
			if(pCallback ~= nil) then
				pCallback(dictData.ret)
			else
                showTip("夺宝请求出错")
			end
		end
	end
	local itemArr = {}
	for k,v in pairs(pCostItemArr) do
		table.insert(itemArr, v)
	end
	table.sort(itemArr, function ( h1, h2 )
		if h1 < h2 then
			return true
		else
			return false
		end
	end)
	local costItemArr = CCArray:create()
	for k, v in ipairs(itemArr) do
		costItemArr:addObject(CCInteger:create(v))
	end
	local args = Network.argsHandlerOfTable({ pTreasureId, pIfUse, costItemArr})
	Network.no_loading_rpc(requestFunc, "fragseize.oneKeySeize" .. pReqeustNum, "fragseize.oneKeySeize", args, true)
	-- requestFunc()
end

local bai_he_num ={[5013011]=0,[5013012]=0,[5013013]=0}
function oneKeySeize( pTreasureId, pIsAutoUse, pCostItemArr,callbackFunc)
    require "script/ui/treasure/oneKeyRob/OneKeyRobService"
    require "script/ui/treasure/oneKeyRob/OneKeyRobData"
	local treasureId = pTreasureId
	local isUse      = pIsAutoUse == true and 1 or 0
    
	--1.等级到达可以抢夺的等级
	if UserModel.getHeroLevel() < OneKeyRobData.getUseLevel() then
		showTip(GetLocalizeStringBy("lcyx_1996", OneKeyRobData.getUseLevel()))
		return 
	end
	--2.背包是否满
	if isBagFull(true) then
		showTip(GetLocalizeStringBy("lcyx_1983"))
		return
	end
	--3.耐力不足
	local costEndurance = tonumber(DB_Loot.getDataById(1).costEndurance)
	if pIsAutoUse == false and UserModel.getStaminaNumber() < costEndurance then
		showTip(GetLocalizeStringBy("lcyx_1984"))
		return
	end
	--4.耐力丹不足
	if pIsAutoUse == true and UserModel.getStaminaNumber() < costEndurance then
		local itemCout = 0
		for k,v in pairs(pCostItemArr) do
			local itemNum = ItemUtil.getCacheItemNumBy(v)
			itemCout = itemCout + itemNum
		end
		if itemCout < 1 then
			showTip(GetLocalizeStringBy("lcyx_1985"))
			return
		end
	end
	-- --5.已拥有所有碎片
	-- local fragments = TreasureData.getTreasureFragments(pTreasureId)
	-- local isHave = true
	-- for k,v in pairs(fragments) do
	-- 	if(TreasureData.getFragmentNum(v) == 0) then
	-- 		isHave = false
	-- 	end
	-- end
	-- if(isHave == true) then
	-- 	--没有对应的碎片
	-- 	showTip(GetLocalizeStringBy("lcyx_1995"))
	-- 	return
	-- end
	local requestNum = 1 --请求次数
	local requestCallback = function ( pRetData )
		--1.用户自检失败 没有任何一个该宝物对应的碎片
		if(pRetData.res == "fail") then
			showTip(GetLocalizeStringBy("lcyx_1986"))
			return
		end

        prints("耐力"..UserModel.getStaminaNumber())
		OneKeyRobData.setInfo(pRetData)
		--1.扣除耐力
		UserModel.addStaminaNumber(-OneKeyRobData.getCostStamina())
        --耐力不足
        local costEndurance = tonumber(DB_Loot.getDataById(1).costEndurance)
        if pIsAutoUse == false and UserModel.getStaminaNumber() < costEndurance then
            showTip(GetLocalizeStringBy("lcyx_1984"))
            if(callbackFunc~=nil)then
                callbackFunc()
            end
            return
        end
		--2.增加银币
		UserModel.addSilverNumber(tonumber(pRetData.silver) or 0)
		--3.增加经验
		local isMaxLv = UserModel.hasReachedMaxLevel()
		UserModel.addExpValue(tonumber(pRetData.exp) or 0)
		--翻牌相关
		if pRetData.card then
			UserModel.addSilverNumber(tonumber(pRetData.card.silver) or 0)
			UserModel.addGoldNumber(tonumber(pRetData.card.gold) or 0)
			UserModel.addSoulNum(tonumber(pRetData.card.soul) or 0)
			UserModel.addSilverNumber(tonumber(pRetData.card.rob) or 0)
		end
		-- prints("requestNum+requestNum+requestNum+requestNum+requestNum+",requestNum)
	    -- 碎片够合成一个宝物
		if(pRetData.res ~= "ok") then
            showTip("累计攻打"..table.count(pRetData.detail).."次")
            local bai_he = {5013011,5013012,5013013}--白鹤碎片id
            for k,v in pairs(pRetData.detail)do
                if(tonumber(v.fragId)~=nil)then
                    bai_he_num[tonumber(v.fragId)] = bai_he_num[tonumber(v.fragId)] + 1
                end
            end
            if(not table.isEmpty(pRetData.card.treasFrag))then
                for k,v in pairs(pRetData.card.treasFrag)do
                    for i=1,3 do
                        if(tonumber(k) == bai_he[i])then
                            bai_he_num[tonumber(k)] = bai_he_num[tonumber(k)] + tonumber(v)
                        end
                    end
                end
            end
            RobTreasureNum = RobTreasureNum + requestNum
            if(RobTreasureNum<SetRobTreasureNum)then
                schedule(CCDirector:sharedDirector():getRunningScene(), fuse, 0.5)
            else
                showTip("夺宝任务已完成")
                finish_table["fragseize_oneKeySeize"] = 1
                if(callbackFunc~=nil)then
                    callbackFunc()
                end
            end
			return
		else
			requestNum = requestNum + 1
            RobTreasureNum = RobTreasureNum + 1
            if(RobTreasureNum>=SetRobTreasureNum)then
                showTip("夺宝任务已完成")
                finish_table["fragseize_oneKeySeize"] = 1
                if(callbackFunc~=nil)then
                    callbackFunc()
                end
                return
            end
			oneKeySeize1(treasureId, isUse, pCostItemArr, requestNum, _requestCallback)
		end
	end
	_requestCallback = requestCallback
	oneKeySeize1(treasureId, isUse, pCostItemArr, requestNum, _requestCallback)
end


--一键夺宝白鹤
function fragseize_oneKeySeize(useAllStamina,callbackFunc,set_num)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("夺宝")
    bai_he_num ={[5013011]=0,[5013012]=0,[5013013]=0}
    if ItemUtil.isTreasBagFull() == true then
        showTip("宝物背包满了")
		return
	end
    if(useAllStamina==true)then
        local userStamina = UserModel.getStaminaNumber()
        SetRobTreasureNum = math.floor(userStamina/2)
    elseif(useAllStamina==false or useAllStamina==nil)then
        SetRobTreasureNum = 3
    elseif(useAllStamina~=nil)then
        require "script/ui/tip/AlertTip"
        AlertTip.showAlert("是否消耗所有耐力夺宝", fragseize_oneKeySeize, true, nil)
        -- showAlert("是否消耗所有耐力夺宝", fragseize_oneKeySeize)
        return
    end
    if(set_num~=nil)then
        SetRobTreasureNum = set_num
    end
    showTip("SetRobTreasureNum ".. SetRobTreasureNum)
    local num = 0

    local needNum = tonumber(DB_Item_treasure.getDataById(501301).need_green_num) or 1
    local fuse_callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            -- printT(dictData)
            if(dictData.ret == "true")then
                showTip("夺宝合成成功")
                if(num>30)then
                    num = num -30
                    for k,v in pairs(bai_he_num) do
                        bai_he_num[k] = bai_he_num[k] - 30
                    end
                else
                    for k,v in pairs(bai_he_num) do
                        bai_he_num[k] = bai_he_num[k] - num
                    end
                    num = 0
                end
                schedule(CCDirector:sharedDirector():getRunningScene(), fuse, 0.5)
            else
                showTip("夺宝合成失败")
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local fuseGreen_callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            --printT(dictData)
            if(dictData.ret == "true")then
                showTip("夺宝合成经验宝物成功")
                num = num - math.floor(num/needNum) * needNum
                schedule(CCDirector:sharedDirector():getRunningScene(), fuse, 0.5)
            else
                showTip("夺宝合成经验宝物失败")
            end

        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    fuse = function()
        --showTip(num)
        if ItemUtil.isTreasBagFull() == true then
            showTip("宝物背包满了")
            return
        end
        num=bai_he_num[5013011]
        for k,v in pairs(bai_he_num) do
            if(v<num)then
                num = v
            end
        end
        --printT(bai_he_num)
        if(num <= 0)then
            showTip("白鹤碎片缺少，无法合成，开始抢夺")
            oneKeySeize(501301, false, {}, callbackFunc)
            return
        elseif(num <=40)then
            local args = CCArray:create()
            args:addObject(CCString:create(501301))--白鹤id
            if(num<=30)then
                args:addObject(CCInteger:create(num))
            else
                args:addObject(CCInteger:create(30))
            end
            Network.no_loading_rpc(fuse_callback, "fragseize.fuse", "fragseize.fuse", args, true)
        else
            local args = Network.argsHandlerOfTable({501301, math.floor(num/needNum)})
            Network.no_loading_rpc(fuseGreen_callback, "fragseize.fuseGreen", "fragseize.fuseGreen", args, true)
        end
    end
    local requestFunc = function( cbFlag, dictData, bRet )
        if (dictData.err == "ok") then
			local info = dictData.ret
            local bai_he = {5013011,5013012,5013013}--白鹤碎片id
            
            for k,v in pairs(info.frag) do 
                for i=1,3 do
                    if(tonumber(v.frag_id)==bai_he[i])then
                        bai_he_num[tonumber(v.frag_id)] = tonumber(v.frag_num)
                    end
                end
            end
            fuse()
		end
	end
    local ActiveInfo_callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            local has_atk_num = tonumber(info.va_active.task["19"]) or 0
            RobTreasureNum = has_atk_num
            if (info.va_active.task["19"] ~= nil and tonumber(info.va_active.task["19"]) >= SetRobTreasureNum and useAllStamina~=true) then
                isGet = true
                showTip("夺宝已挑战，请勿重复操作")
                finish_table["fragseize_oneKeySeize"] = 1
                if(callbackFunc~=nil)then
                    callbackFunc()
                end
                return
            end
            Network.no_loading_rpc(requestFunc, "fragseize.getSeizerInfo", "fragseize.getSeizerInfo", nil, true)
        end
    end
    Network.no_loading_rpc(ActiveInfo_callback, "active.getActiveInfo", "active.getActiveInfo", nil, true)
end


function fragseize_oneKeySeize_set_num_UI(showDialog)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    local itemArr = {["1"]=10041, ["5"]=10042, ["10"]=10043}
    local hasNum = math.floor(UserModel.getStaminaNumber()/2)
    for k,itemId in pairs(itemArr) do
        local energyInfo = ItemUtil.getCacheItemInfoBy(itemId) -- 耐力丹
        if not table.isEmpty(energyInfo) and tonumber(energyInfo.item_num) > 0 then
            hasNum = hasNum + tonumber(energyInfo.item_num)*tonumber(k)
        end
    end
    -- if(hasNum>600)then
    --     hasNum = 600
    -- end
    local function setNum(num)
        if(num<=0)then
            showTip("夺宝次数必须大于0")
            return 
        end
        -- showTip(num)
        local function callback()
            fragseize_oneKeySeize(true,nil,num)
        end
        useItem_stamina(num*2,callback)
    end
    local function requestFunc(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local info = dictData.ret
            local PseasonNum = tonumber(info.period) -- 当前是第几季
            local curDay = tonumber(info.day) -- 当前是活动第几天
            local festivalAct = ActivityConfigUtil.getDataByKey("festivalAct").data
            local festivalActReward = ActivityConfigUtil.getDataByKey("festivalActReward").data
            local periodStartTime = TimeUtil.getIntervalByTimeDesString(festivalAct[PseasonNum].start_time)
            local periodEndTime = TimeUtil.getIntervalByTimeDesString(festivalAct[PseasonNum].end_time)
            local periodDayNum = math.ceil((periodEndTime - periodStartTime)/86400)--当前季总天数
            local taskList2 = festivalAct[PseasonNum].mission_2
            local duobao = string.find(taskList2,"104008")
            if(duobao~=nil and periodDayNum*PseasonNum==curDay)then
                local taskInfo = info.data[tostring(PseasonNum)]["1"]
                local goalNum = tonumber(festivalActReward[104008].finish) -- 目标次数
                local finishNum = tonumber(taskInfo["104008"][1]) -- 已完成次数
                local needNum = math.max(goalNum - finishNum,math.floor(UserModel.getStaminaNumber()/2))-- 默认攻打次数为还需任务次数和耐力可打次数最大值
                local desc = "狂欢夺宝进度：" .. finishNum.. "/".. goalNum..",还需"..math.max(goalNum - finishNum,0).."次"
                if(showDialog~=false)then
                    if(goalNum - finishNum<=0)then
                        goalNum = hasNum
                    end
                    creteNumSelectUI(setNum,nil,0,0,needNum,desc,"夺宝次数",goalNum)
                end
            else
                if(showDialog~=false)then
                    creteNumSelectUI(setNum,nil,0,0,math.floor(UserModel.getStaminaNumber()/2),"夺宝","夺宝次数",hasNum)
                end
            end
        end
    end
    if(isFestivalActOpen())then
        rpcCountIndex = rpcCountIndex +1
        Network.no_loading_rpc(requestFunc, "festivalact.getInfo"..rpcCountIndex, "festivalact.getInfo", nil, true)
    else
        if(showDialog~=false)then
            creteNumSelectUI(setNum,nil,0,0,math.floor(UserModel.getStaminaNumber()/2),"夺宝","夺宝次数",hasNum)
        end
    end
end

-- 名将突围购买次数
function sortie_buyAtkNum()
    showTip("名将突围购买次数")
    if not DataCache.getSwitchNodeState(ksSwitchBorder, false) then
        showTip("名将突围，等级未达到")
        return
    end
    require "script/ui/border/BorderData"
    local cost = 0
    local num = tonumber(default_value["sortie_buyAtkNum"]) or 2 -- 自定义 名将突围购买次数
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("名将突围购买次数成功")
            UserModel.addGoldNumber(-cost)
            -- BorderData.addBuyAttackNum(pNum)
            finish_table["sortie_buyAtkNum"] = 1
            -- sortie_getInfo()
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local isGet = false
            local info = dictData.ret
            BorderData.setNetInfo(info)
            local buy_attack_num = tonumber(info.buy_attack_num)
            if (buy_attack_num >= num) then
                isGet = true
                showTip("名将突围次数已购买，请勿重复操作")
                finish_table["sortie_buyAtkNum"] = 1
                -- sortie_getInfo()
                return
            end
            num = num - buy_attack_num
            cost = BorderData.getTotalBuyAttackTimekCost(num)
            showTip("名将突围购买" .. num .. "次")
            local args = CCArray:create()
            args:addObject(CCInteger:create(num))
            Network.no_loading_rpc(callback,"sortie.buyAttackNum","sortie.buyAttackNum",args,true)
        end
    end
    Network.no_loading_rpc(requestFunc, "sortie.getInfo", "sortie.getInfo", nil, true)
end

--名将突围
function sortie_getInfo()
    showTip("名将突围")
    if not DataCache.getSwitchNodeState(ksSwitchBorder, false) then
        showTip("名将突围，等级未达到")
        return
    end
    require "db/DB_Where_is_treasure"
    local border_index = 2 -- 攻打敌人编号0~2
    local border_pass_copy = {}
    local DBdata = DB_Where_is_treasure.getDataById(1)
    local copy_num_each_level = tonumber(DBdata.copy_num_each_level) -- 每关敌人数量
    local free_times = tonumber(DBdata.free_times) -- 免费攻打次数
    local num = 0 -- 剩余攻打次数
    local curRound = 1 -- 当前回合
    local MAXROUND = 4 -- 最大回合数
    local box_num = 0 -- 当前关卡箱子等级
    local isPass = 0 -- 是否可以进入下一关
    local buyBoxNum = default_value["sortie_openBoxNum"] or 1 -- 指定等级的箱子购买数量
    local buyBoxLv = default_value["sortie_openBoxLv"] or 1 -- 设定箱子购买等级
    if(buyBoxLv>3)then
        buyBoxLv = 3
    end
    if(buyBoxLv<0)then
        buyBoxLv = 0
    end
    if(buyBoxNum>MAXROUND)then
        buyBoxNum = MAXROUND
    end
    if(buyBoxNum<1)then
        buyBoxNum = 1
    end
    local getBoxCost=function( BoxLv )
        if BoxLv == 0 then 
            return 0
        end
        local treasure_times_cost = string.split(DBdata.treasure_times_cost,",")
        if(BoxLv>#treasure_times_cost)then
            return -1
        end
        return tonumber(string.split(treasure_times_cost[BoxLv],"|")[2])
    end
    local box_callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("名将突围开"..box_num.."级宝箱成功")
            if(box_num>0)then
                --修改金币todo
                local cost = getBoxCost(box_num) -- 当前宝箱花费
                if(cost>0)then
                    UserModel.addGoldNumber(-cost)
                else
                    showTip("获取宝箱价格出现错误")
                    return
                end
            end
            if(box_num>=buyBoxLv)then
                buyBoxNum = buyBoxNum - 1
            end
            box_num = box_num + 1
            schedule(CCDirector:sharedDirector():getRunningScene(), sortie_openBox, 0.2)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local atk_callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            --printT(dictData)
            num = num - 1
            local info = dictData.ret
            if(tonumber(info.hp)<=0)then
                showTip("名将突围击杀第"..curRound.."关"..border_index.."号敌人成功")
                table.insert(border_pass_copy,border_index)
                if(tonumber(info.pass)==1)then
                    prints("名将突围第"..curRound.."关已通关")
                    isPass = 1
                    schedule(CCDirector:sharedDirector():getRunningScene(), sortie_openBox, 0.2)
                else
                    border_index = border_index + 1
                    if(isPass==1)then
                        prints("名将突围第"..curRound.."关已通关")
                        schedule(CCDirector:sharedDirector():getRunningScene(), sortie_openBox, 0.2)
                    else
                        schedule(CCDirector:sharedDirector():getRunningScene(), sortie_attack, 0.2)
                    end
                end
            else
                showTip("名将突围攻打第"..curRound.."关"..border_index.."号敌人成功")
                schedule(CCDirector:sharedDirector():getRunningScene(), sortie_attack, 0.2)
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    sortie_openBox = function()
        if(box_num<buyBoxLv or box_num==0)then
            Network.no_loading_rpc(box_callback,"sortie.openBox","sortie.openBox",nil,true)
            return
        else
            if(buyBoxNum>0 and box_num<buyBoxLv+1 )then
                Network.no_loading_rpc(box_callback,"sortie.openBox","sortie.openBox",nil,true)
                return
            end
        end
        local remain_army = (MAXROUND-curRound)*copy_num_each_level -- 后面几关剩余敌人
        prints("remain_army = "..remain_army.."\nnum = "..num)
        if(remain_army<num and table.count(border_pass_copy)<copy_num_each_level)then
            schedule(CCDirector:sharedDirector():getRunningScene(), sortie_attack, 0.2)
        else
            schedule(CCDirector:sharedDirector():getRunningScene(), sortie_enterNext, 0.2)
        end
    end
    sortie_attack = function()
        if(num<=0)then
            showTip("名将突围次数用完，请勿重复操作")
            finish_table["sortie_getInfo"] = 1
            return
        end
        if(border_index>=copy_num_each_level)then
            border_index = 0
        end
        --printT(border_pass_copy)
        for k,v in pairs(border_pass_copy)do
            if(border_index == v)then
                border_index = border_index + 1
                sortie_attack()
                return 
            end
        end
        --prints("border_index = "..border_index)
        --if(1)then return end
        local args = CCArray:create()
        args:addObject(CCInteger:create(border_index))
        Network.no_loading_rpc(atk_callback,"sortie.attack","sortie.attack",args,true)
    end
    local enter_callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
			--printT(dictData)
            border_pass_copy = {}
            local info = dictData.ret
            curRound = curRound + 1
            box_num = 0
            isPass = 0
            if(num<=0)then
                
                showTip("名将突围次数用完，请勿重复操作")
                finish_table["sortie_getInfo"] = 1
                return
            end
            schedule(CCDirector:sharedDirector():getRunningScene(), sortie_attack, 0.2)
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    sortie_enterNext = function()
        showTip("名将突围进入下一关")
        if(curRound>=MAXROUND)then
            showTip("名将突围关卡攻打完毕")
            schedule(CCDirector:sharedDirector():getRunningScene(), sortie_attack, 0.2)
            return
        end
        Network.no_loading_rpc(enter_callback,"sortie.enterNext","sortie.enterNext",nil,true)
    end
	local requestFunc = function(cbFlag,dictData,bRet)
		if dictData.err == "ok" then
			-- printT(dictData)
            -- if(1)then return end
            local info = dictData.ret
            local attack_num = tonumber(info.attack_num)
            local buy_attack_num = tonumber(info.buy_attack_num)
            num = free_times + buy_attack_num - attack_num
            if(num<=0)then
                showTip("名将突围次数用完，请勿重复操作")
                finish_table["sortie_getInfo"] = 1
                return
            end
            border_pass_copy = {}
            curRound = tonumber(info.round)
            buyBoxNum = buyBoxNum - curRound + 1
            box_num = tonumber(info.box_num)
            isPass = 0
            for k,v in pairs(info.passCopy)do
                table.insert(border_pass_copy,tonumber(v))
            end
            local border_box_index = tonumber(info.boxCopy)
            if(border_box_index == -1)then
                schedule(CCDirector:sharedDirector():getRunningScene(), sortie_attack, 0.2)
            else
                isPass = 1
                schedule(CCDirector:sharedDirector():getRunningScene(), sortie_openBox, 0.2)
            end
		end
	end
	Network.no_loading_rpc(requestFunc,"sortie.getInfo","sortie.getInfo",nil,true)
end

--皇陵寻宝
function robtomb_rob()
    showTip("皇陵寻宝")
    if(not ActivityConfigUtil.isActivityOpen("robTomb"))then
        showTip("当前不在皇陵寻宝活动期间")
        finish_table["robtomb_rob"] = 1
        return
    end
    local leftFreeTime = 0
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("皇陵寻宝成功，寻宝"..leftFreeTime.."次")
            finish_table["robtomb_rob"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
	local function requestFunc(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            -- printT(dictData)
            local isGet = false
            local info = dictData.ret
            require "db/DB_Vip"
            local vipArr = DB_Vip.getArrDataByField("level", UserModel.getVipLevel())
            local totalFreeTime = tonumber(vipArr[1].ernieFreeTimes)
            local useTime = tonumber(info.today_free_num)
            leftFreeTime = totalFreeTime - useTime
            if(leftFreeTime <= 0) then
                isGet = true
                showTip("皇陵寻宝免费次数用完")
                finish_table["robtomb_rob"] = 1
                return
            end
            if(not isGet)then
                local args = CCArray:create()
                args:addObject(CCString:create(tostring(leftFreeTime)))
                Network.no_loading_rpc(callback, "robtomb.rob", "robtomb.rob", args, true)
            end
        end
	end 
    local args = CCArray:create()
	args:addObject(CCString:create(tostring(1)))
	Network.no_loading_rpc(requestFunc, "robtomb.getMyRobInfo", "robtomb.getMyRobInfo", args, true)
end

function festivalact_signReward()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("节日狂欢")
    if(not isFestivalActOpen())then
        showTip("当前不在节日狂欢活动期间")
        finish_table["festivalact_signReward"] = 1
        return
    end

    local taskInfo = {}
    local curDay=0
    local function signReward(id)
        local day = math.fmod(id,10)
		local function requestFunc( cbFlag, dictData, bRet )
			if dictData.err == "ok" then
                showTip("节日狂欢第"..day.."天补签成功")
            else
                showTip(showTip("节日狂欢第"..day.."天补签失败"))
			end
		end
		local args = CCArray:create()
		args:addObject(CCInteger:create(id))
		Network.no_loading_rpc(requestFunc, "festivalact.signReward", "festivalact.signReward", args, true)
	end
    local function taskReward(id)
        local function requestFunc( cbFlag, dictData, bRet )
            local day = math.fmod(id,10)
            if dictData.err == "ok" then
                showTip("节日狂欢第"..day.."天签到成功")
                finish_table["festivalact_signReward"] = 1
            else
                showTip("节日狂欢第"..day.."天签到失败")
            end
        end
       
        local args = CCArray:create()
        args:addObject(CCInteger:create(id))
        Network.no_loading_rpc(requestFunc, "festivalact.taskReward", "festivalact.taskReward", args, true)
    end
    local function requestFunc(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            -- printT(dictData)
            -- if(1)then return end
            local isGet = true
            local info = dictData.ret
            local PseasonNum = tonumber(info.period) -- 当前是第几季
            curDay = tonumber(info.day) -- 当前是活动第几天
            local festivalAct = ActivityConfigUtil.getDataByKey("festivalAct").data
            local festivalActReward = ActivityConfigUtil.getDataByKey("festivalActReward").data
            local startTime = tonumber(ActivityConfigUtil.getDataByKey("festivalAct").start_time)
            local endTime = tonumber(ActivityConfigUtil.getDataByKey("festivalAct").end_time)
            local periodStartTime = TimeUtil.getIntervalByTimeDesString(festivalAct[PseasonNum].start_time)
            local periodEndTime = TimeUtil.getIntervalByTimeDesString(festivalAct[PseasonNum].end_time)
            local periodDayNum = math.ceil((periodEndTime - periodStartTime)/86400)--当前季总天数
            local dayNum = math.ceil((endTime - startTime)/86400)-1 --活动总天数
            taskInfo = info.data[tostring(PseasonNum)]["1"]
            -- printT(taskInfo)
            -- printT(taskInfo[101001])
            --101001|101002|101003 签到 101004|101005|101006
            local statues = tonumber(taskInfo[tostring(101000+curDay)][2])
            if(statues==1)then
                taskReward(101000+curDay)
            else
                showTip("节日狂欢第"..curDay.."天已签到，请勿重复操作")
                for i=1,curDay-1 do
                    local statues = 0 
                    if(i<=periodDayNum)then
                        statues = tonumber(info.data[tostring(1)]["1"][tostring(101000+i)][2])
                    else
                        statues = tonumber(taskInfo[tostring(101000+i)][2])
                    end
                    if(statues==0 or statues == 1)then
                        local function _signReward()
                            signReward(101000+i)
                        end
                        schedule(CCDirector:sharedDirector():getRunningScene(),_signReward,0.2*i)
                    end
                end
                finish_table["festivalact_signReward"] = 1
            end
        end
	end 
	rpcCountIndex = rpcCountIndex +1
	Network.no_loading_rpc(requestFunc, "festivalact.getInfo"..rpcCountIndex, "festivalact.getInfo", nil, true)
end

-- 竞技场挑战指定次数
function arena_challenge_set_num(num,callbackFunc,useAllStamina)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("竞技场挑战")
    require "script/ui/arena/ArenaBatchData"
    local setNum = num
    if(useAllStamina==true)then
        setNum = math.floor(UserModel.getStaminaNumber()/2)
    else
        useItem_stamina(setNum*2)
    end
    showTip("竞技场攻打"..setNum.."次")
    local p_num = 0
    local position = 1
    local atkedUid = 0
    if not DataCache.getSwitchNodeState(ksSwitchArena, false) then
        showTip("竞技场，等级未达到")
        return
    end
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("竞技场挑战成功")
            UserModel.addStaminaNumber(-2 * p_num)
            setNum = setNum - p_num
            if(setNum <= 0)then
                if(callbackFunc~=nil)then
                    callbackFunc()
                end
            else
                schedule(nil,arena_challenge_atk,0.2)
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    function arena_challenge_atk()
        local max_num = ArenaBatchData.getFightMaxNum()
        p_num = max_num
        if (max_num > setNum) then
            p_num = setNum
        end
        if (p_num > 0) then
            local args = CCArray:create()
            args:addObject(CCInteger:create(position)) -- 攻打第几名
            args:addObject(CCInteger:create(atkedUid)) -- 攻打的人的uid
            args:addObject(CCInteger:create(p_num)) -- 攻打次数0~50
            args:addObject(CCInteger:create(1)) -- 是否攻打多次0~1
            Network.no_loading_rpc(callback, "arena.challenge", "arena.challenge", args, true)
        else
            showTip("耐力不足")
        end
    end
    local info_callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            local info = dictData.ret
            if (tonumber(info.res.reward_time) <= 0) then
                isGet = true
                showTip("竞技场发奖中，无法攻打")
                return
            end
            local my_pos = tonumber(info.res.position)
            position = my_pos + 1
            for k,v in pairs(info.res.opponents)do
                if(tonumber(k)>my_pos)then
                    position = tonumber(k)
                    atkedUid = tonumber(v.uid)
                    break
                end
            end
            arena_challenge_atk()
        end
    end
    Network.no_loading_rpc(info_callback, "arena.getArenaInfo", "arena.getArenaInfo", nil, true)
end

function arena_challenge_set_num_UI(showDialog)
    local curTime = TimeUtil.getSvrTimeByOffset()
    if(curTime>=TimeUtil.getIntervalByTime("220000") and curTime<=TimeUtil.getIntervalByTime("223000") )then
        showTip("当前时间竞技场无法攻打")
        return
    end
    --背包是否满
    if isBagFull(true) then
        showTip("背包满了")
        stopSweep()
        return
    end
    local itemArr = {["1"]=10041, ["5"]=10042, ["10"]=10043}
    local hasNum = math.floor(UserModel.getStaminaNumber()/2)
    for k,itemId in pairs(itemArr) do
        local energyInfo = ItemUtil.getCacheItemInfoBy(itemId) -- 耐力丹
        if not table.isEmpty(energyInfo) and tonumber(energyInfo.item_num) > 0 then
            hasNum = hasNum + tonumber(energyInfo.item_num)*tonumber(k)
        end
    end
    -- if(hasNum>600)then
    --     hasNum = 600
    -- end
    local function setNum(num)
        if(num<=0)then
            showTip("竞技场次数必须大于0")
            return 
        end
        -- showTip(num)
        local function callback()
            arena_challenge_set_num(num,nil,false)
        end
        useItem_stamina(num*2,callback)
    end
    local function requestFunc(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local info = dictData.ret
            local PseasonNum = tonumber(info.period) -- 当前是第几季
            local curDay = tonumber(info.day) -- 当前是活动第几天
            local festivalAct = ActivityConfigUtil.getDataByKey("festivalAct").data
            local festivalActReward = ActivityConfigUtil.getDataByKey("festivalActReward").data
            local periodStartTime = TimeUtil.getIntervalByTimeDesString(festivalAct[PseasonNum].start_time)
            local periodEndTime = TimeUtil.getIntervalByTimeDesString(festivalAct[PseasonNum].end_time)
            local periodDayNum = math.ceil((periodEndTime - periodStartTime)/86400)--当前季总天数
            local taskList2 = festivalAct[PseasonNum].mission_2
            local jingji = string.find(taskList2,"111008")
            if(jingji~=nil and periodDayNum*PseasonNum==curDay)then
                local taskInfo = info.data[tostring(PseasonNum)]["1"]
                local goalNum = tonumber(festivalActReward[111008].finish) -- 目标次数
                local finishNum = tonumber(taskInfo["111008"][1]) -- 已完成次数
                local needNum = math.max(goalNum - finishNum,math.floor(UserModel.getStaminaNumber()/2))-- 默认攻打次数为还需任务次数和耐力可打次数最大值
                local desc = "狂欢竞技场进度：" .. finishNum.. "/".. goalNum..",还需"..math.max(goalNum - finishNum,0).."次"
                if(showDialog~=false)then
                    if(goalNum - finishNum<=0)then
                        goalNum = hasNum
                    end
                    creteNumSelectUI(setNum,nil,0,0,needNum,desc,"竞技场次数",goalNum)
                end
            else
                if(showDialog~=false)then
                    creteNumSelectUI(setNum,nil,0,0,math.floor(UserModel.getStaminaNumber()/2),"竞技场","竞技场次数",hasNum)
                end
            end
        end
    end
    if(isFestivalActOpen())then
        rpcCountIndex = rpcCountIndex +1
        Network.no_loading_rpc(requestFunc, "festivalact.getInfo"..rpcCountIndex, "festivalact.getInfo", nil, true)
    else
        if(showDialog~=false)then
            creteNumSelectUI(setNum,nil,0,0,math.floor(UserModel.getStaminaNumber()/2),"竞技场","竞技场次数",hasNum)
        end
    end
end

-- 猎魂2亿银币（不留五星魂）不限制次数
function hunt_rapidHunt_unLimit4(callbackFunc)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("猎魂1000w")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("猎魂1000w成功")
            if(callbackFunc~=nil)then
                schedule(nil,function()callbackFunc()end,0.2)
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local args = Network.argsHandlerOfTable({4}) -- {选择银币档位1~4, {保留品质4,5}}
    Network.no_loading_rpc(callback, "hunt.rapidHunt", "hunt.rapidHunt", args, true)
end

-- 猎魂1000w银币（不留五星魂）不限制次数
function hunt_rapidHunt_unLimit(callbackFunc)
    showTip("猎魂1000w")
    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            showTip("猎魂1000w成功")
            if(callbackFunc~=nil)then
                callbackFunc()
            end
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local args = Network.argsHandlerOfTable({1}) -- {选择银币档位1~4, {保留品质4,5}}
    Network.no_loading_rpc(callback, "hunt.rapidHunt", "hunt.rapidHunt", args, true)
end

--副本扫荡
function ncopy_sweep(defeat_num,callbackFunc)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    -- useItem_energy(defeat_num*5)
    showTip("查询缓存副本信息")
    require "db/DB_Copy"
    require "db/DB_Stronghold"
    local dictData = DataCache.getNcopyInfo()
    local info = dictData.copy_list
    local maxCopyId = 1
    local num = 0
    for k,v in pairs(info) do
        if(tonumber(v.copy_id)>maxCopyId)then
            if(tonumber(v.va_copy_info.progress[v.copy_id.."010"]) == 5 and tonumber(v.va_copy_info.defeat_num[v.copy_id.."010"]) > 0)then
                maxCopyId = tonumber(v.copy_id)
                num = tonumber(v.va_copy_info.defeat_num[v.copy_id.."010"])
            end
        end
    end
    local needNum = 0
    if(defeat_num>num)then
        needNum = defeat_num-num
        defeat_num = num
    end
    local curCopyId = maxCopyId
    local curFortId = maxCopyId.."010"
    -- 战10次回调
    function _fight10Callback( cbFlag, dictData, bRet )
        -- printT(dictData)
        if(dictData.err == "ok" and dictData.ret) then
            require "db/DB_Copy"
            local copy_name = DB_Copy.getDataById(curCopyId).name
            require "db/DB_Stronghold"
            local army_name = DB_Stronghold.getDataById(curFortId).name
            showTip("攻打副本"..copy_name.." "..army_name.." " .."3星 "..defeat_num.."次")
            if(dictData.ret.sweepcd)then
                DataCache.setSweepCoolTime(tonumber(dictData.ret.sweepcd))
            end
            DataCache.addDefeatNumByCopyAndFort( curCopyId, curFortId, -tonumber(defeat_num) )
            
            local curCopyCastUnit = DB_Stronghold.getDataById(tonumber(curFortId)).cost_energy_hard
            local bodyCost = curCopyCastUnit * defeat_num
            UserModel.addEnergyValue(-bodyCost)
            if(needNum>0)then
                schedule(nil,function()ncopy_sweep(needNum,callbackFunc)end,0.3)
                return
            end
            if(callbackFunc~=nil)then
                callbackFunc()
            end
        else
            printT(dictData)
        end
    end
    local args = Network.argsHandler(curCopyId, curFortId, 3, defeat_num)
    -- prints("curCopyId："..curCopyId.." curFortId："..curFortId.." defeat_num："..defeat_num)
    Network.no_loading_rpc(_fight10Callback, "ncopy.sweep", "ncopy.sweep", args, true)
end
--副本扫荡按钮调用
function ncopy_sweep_set_num_UI(showDialog)
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    local itemArr = {["1"]=10031, ["5"]=10032, ["10"]=10033}
    local hasNum = math.floor(UserModel.getEnergyValue()/5)
    for k,itemId in pairs(itemArr) do
        local energyInfo = ItemUtil.getCacheItemInfoBy(itemId) -- 体力丹
        if not table.isEmpty(energyInfo) and tonumber(energyInfo.item_num) > 0 then
            hasNum = hasNum + tonumber(energyInfo.item_num)*tonumber(k)
        end
    end
    -- if(hasNum>600)then
    --     hasNum = 600
    -- end
    local function setNum(num)
        if(num<=0)then
            showTip("副本扫荡次数必须大于0")
            return 
        end
        useItem_energy(num*5,function()ncopy_sweep(num)end)
    end
    local function requestFunc(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local info = dictData.ret
            local PseasonNum = tonumber(info.period) -- 当前是第几季
            local curDay = tonumber(info.day) -- 当前是活动第几天
            local festivalAct = ActivityConfigUtil.getDataByKey("festivalAct").data
            local festivalActReward = ActivityConfigUtil.getDataByKey("festivalActReward").data
            local periodStartTime = TimeUtil.getIntervalByTimeDesString(festivalAct[PseasonNum].start_time)
            local periodEndTime = TimeUtil.getIntervalByTimeDesString(festivalAct[PseasonNum].end_time)
            local periodDayNum = math.ceil((periodEndTime - periodStartTime)/86400)--当前季总天数
            local taskList2 = festivalAct[PseasonNum].mission_2
            local fuben = string.find(taskList2,"102008")
            if(fuben~=nil and periodDayNum*PseasonNum==curDay)then
                local taskInfo = info.data[tostring(PseasonNum)]["1"]
                local goalNum = tonumber(festivalActReward[102008].finish) -- 目标次数
                local finishNum = tonumber(taskInfo["102008"][1]) -- 已完成次数
                local needNum = math.max(goalNum - finishNum,math.floor(UserModel.getEnergyValue()/5))-- 默认攻打次数为还需任务次数和耐力可打次数最大值
                local desc = "狂欢副本进度：" .. finishNum.. "/".. goalNum..",还需"..math.max(goalNum - finishNum,0).."次"
                if(showDialog~=false)then
                    if(goalNum - finishNum<=0)then
                        goalNum = hasNum
                    end
                    creteNumSelectUI(setNum,nil,0,0,needNum,desc,"副本次数",goalNum)
                end
            else
                if(showDialog~=false)then
                    creteNumSelectUI(setNum,nil,0,0,math.floor(UserModel.getEnergyValue()/5),"副本","副本次数",hasNum)
                end
            end
        end
    end
    if(isFestivalActOpen())then
        rpcCountIndex = rpcCountIndex +1
        Network.no_loading_rpc(requestFunc, "festivalact.getInfo"..rpcCountIndex, "festivalact.getInfo", nil, true)
    else
        if(showDialog~=false)then
            creteNumSelectUI(setNum,nil,0,0,math.floor(UserModel.getEnergyValue()/5),"副本","副本次数",hasNum)
        end
    end
end

--使用体力丹
function doUseItem_energy( itemId, pItemNum ,addEnergy,_callBack)
    if(pItemNum<=0)then
        if(_callBack ~= nil)then
            _callBack()
        end
        return
    end
	local energyInfo = ItemUtil.getCacheItemInfoBy(itemId) -- 体力丹
	if table.isEmpty(energyInfo) or tonumber(energyInfo.item_num) <= 0 then
		showTip("体力丹不足")
		return
	end
	-- 使用回调
	local useItemCallback = function ( cbFlag, dictData, bRet )
		if (dictData.err == "ok") then
			showTip("使用体力丹成功，体力+ ".. addEnergy*pItemNum)
			UserModel.addEnergyValue(addEnergy*pItemNum)
			if(_callBack ~= nil)then
				_callBack()
			end
		end
	end
	local args = Network.argsHandler(energyInfo.gid, energyInfo.item_id, pItemNum)
	Network.no_loading_rpc(useItemCallback, "bag.useItem","bag.useItem", args, true)
end

function useItem_energy(needEnergy,_callBack)
    local itemArr = {10032,10031,10033}
    local itemAddTimes = {5,1,10}
    local needNum = math.ceil((needEnergy-UserModel.getEnergyValue())/5)
    if(needNum<=0)then
        if(_callBack ~= nil)then
            _callBack()
        end
        return
    end
    for k=1,#itemArr do
        local itemId = itemArr[k]
        local times = itemAddTimes[k]
        local energyInfo = ItemUtil.getCacheItemInfoBy(itemId) -- 体力丹
        if not table.isEmpty(energyInfo) and tonumber(energyInfo.item_num) > 0 then
            if(tonumber(energyInfo.item_num)*times>=needNum)then
                doUseItem_energy(itemId,math.ceil(needNum/times),times*5,_callBack)
                needNum = 0
                break
            else
                doUseItem_energy(itemId,tonumber(energyInfo.item_num),times*5,_callBack)
                needNum = needNum - tonumber(energyInfo.item_num)
                showTip(energyInfo.itemDesc.name.."已用完")
                break
            end
        end
    end
end


--使用耐力丹
function doUseItem_stamina( itemId,pItemNum ,addStamina,_callBack)
    if(pItemNum<=0)then
        if(_callBack ~= nil)then
            _callBack()
        end
        return
    end
	local energyInfo = ItemUtil.getCacheItemInfoBy(itemId) -- 耐力丹
	if table.isEmpty(energyInfo) or tonumber(energyInfo.item_num) <= 0 then
		showTip("耐力丹不足")
		return
	end
	-- 使用回调
	local useItemCallback = function ( cbFlag, dictData, bRet )
		if (dictData.err == "ok") then
			showTip("使用耐力丹成功，耐力+ ".. addStamina*pItemNum)
			UserModel.addStaminaNumber(addStamina*pItemNum)
			if(_callBack ~= nil)then
				_callBack()
			end
		end
	end
	local args = Network.argsHandler(energyInfo.gid, energyInfo.item_id, pItemNum)
	Network.no_loading_rpc(useItemCallback, "bag.useItem","bag.useItem", args, true)
end
function useItem_stamina(needStamina,_callBack)
    local itemArr = {10042,10041,10043}
    local itemAddTimes = {5,1,10}
    local needNum = math.ceil((needStamina-UserModel.getStaminaNumber())/2)
    if(needNum<=0)then
        if(_callBack ~= nil)then
            _callBack()
        end
        return
    end
    for k=1,#itemArr do
        local itemId = itemArr[k]
        local times = itemAddTimes[k]
        local energyInfo = ItemUtil.getCacheItemInfoBy(itemId) -- 耐力丹
        -- printT(energyInfo)
        
        if not table.isEmpty(energyInfo) and tonumber(energyInfo.item_num) > 0 then
            if(tonumber(energyInfo.item_num)*times>=needNum)then
                doUseItem_stamina(itemId,math.ceil(needNum/times),times*2,_callBack)
                needNum = 0
                break
            else
                doUseItem_stamina(itemId,tonumber(energyInfo.item_num),times*2,_callBack)
                needNum = needNum - tonumber(energyInfo.item_num)
                showTip(energyInfo.itemDesc.name.."已用完")
                break
            end
        end
    end
end

--使用需要选择物品的礼包
function useSelectItem(item_id,item_num,callbackFunc)
    if(item_num<=0)then
        if(callbackFunc ~= nil)then
            schedule(nil,function()callbackFunc()end,0.2)
        end
        return
    end
    local item_name = ItemUtil.getItemById(item_id).name
	local Info = ItemUtil.getCacheItemInfoBy(item_id)
	if table.isEmpty(Info) or tonumber(Info.item_num) <= 0 then
		showTip(tostring(item_name).."数量不足")
		return
	end
    local choose_items = ItemUtil.getItemById(item_id).choose_items
    -- printT(Info)
    -- prints(choose_items)
    -- if(1)then return end
	-- 使用回调
	local useItemCallback = function ( cbFlag, dictData, bRet )
        printT(dictData)
		if (dictData.err == "ok") then
			showTip("使用"..tostring(item_name).."*"..item_num)
            printT(Info)
            local reward=string.split(choose_items,",")[1]
            local itemInfo = string.split(reward, "|")
            local itemId  = tonumber(itemInfo[2])
            local itemNum  = tonumber(itemInfo[3])
            showTip("获得奖励："..tostring(ItemUtil.getItemById(itemId).name).."|"..itemNum.."*"..item_num)
            
            if(callbackFunc ~= nil)then
                schedule(nil,function()callbackFunc()end,0.2)
            end
		end
	end
	local args = Network.argsHandler(Info.gid, Info.item_id, 0,item_num)
	Network.no_loading_rpc(useItemCallback, "bag.useGift","bag.useGift", args, true)
end

--使用物品
function useItem(item_id,item_num,callbackFunc)
    if(item_num<=0)then
        if(callbackFunc ~= nil)then
            schedule(nil,function()callbackFunc()end,0.2)
        end
        return
    end
    local item_name = ItemUtil.getItemById(item_id).name
	local Info = ItemUtil.getCacheItemInfoBy(item_id)
	if table.isEmpty(Info) or tonumber(Info.item_num) <= 0 then
		showTip(tostring(item_name).."数量不足")
		return
	end
    printT(Info)
    -- if(1)then return end
	-- 使用回调
	local useItemCallback = function ( cbFlag, dictData, bRet )
        printT(dictData)
		if (dictData.err == "ok") then
            if(dictData.ret.ret~="ok")then
                showTip(dictData.ret.ret)
                return
            end
			showTip("使用"..tostring(item_name).."*"..item_num)
            local reward=""
            for k,v in pairs(dictData.ret.drop.item)do
                reward = reward..tostring(ItemUtil.getItemById(k).name).."*"..v.."\n"
            end
            showTip("获得奖励："..reward)
            if(callbackFunc ~= nil)then
                schedule(nil,function()callbackFunc()end,0.2)
            end
		end
	end
	local args = Network.argsHandler(Info.gid, Info.item_id, item_num)
	Network.no_loading_rpc(useItemCallback, "bag.useItem","bag.useItem", args, true)
end

--悬赏任务
function rewardtask_donateItem()
    showTip("悬赏任务")
    require "db/DB_Daily_bounty_id"
    require "script/ui/rewardtask/RewardTaskDef"
    readDefaultValue(false)
    local itemArray = {}
    local info = nil
    local taskInfo = nil
    local goalNum = 0
    local isLoading = false
    local rewardtaskUI = nil
    local function rewardtask_reward()
        if(isLoading)then
            showTip("请求已发送，请等待")
            return
        end
        isLoading = true
        local function requestFunc( cbFlag, dictData, bRet )
            isLoading = false
            if dictData.err == "ok" then
                showTip("悬赏任务领奖成功")
                -- printT(dictData)
                info.task_id = dictData.ret
                info.procedure = 0
                info.task_num = tonumber(info.task_num)-1
                if(info.task_num>0)then
                    rewardtaskUI(dictData.ret)
                else
                    showTip("悬赏任务次数用完")
                    -- 关闭页面
                    if(alertLayer~=nil)then
                        alertLayer:removeFromParentAndCleanup(true)
                        alertLayer = nil
                    end
                end
            end
        end
        
        Network.no_loading_rpc(requestFunc, "rewardtask.reward", "rewardtask.reward", nil, true)
    end
    local function donateItem(arrItem,useGold,costNum)
        if(isLoading)then
            showTip("请求已发送，请等待")
            return
        end
        isLoading = true
        local function requestFunc( cbFlag, dictData, bRet )
            isLoading = false
            if dictData.err == "ok" then
                showTip("悬赏任务捐赠成功")
                -- printT(dictData)
                itemArray={}
                rewardtask_reward()
            end
        end
        if useGold==1 then
            UserModel.addGoldNumber(-costNum)
        end
        local args = CCArray:create()
        local args1 = CCDictionary:create()
        if table.isEmpty(arrItem) then
            args:addObject(CCArray:create())
            args:addObject(CCInteger:create(useGold))
        else
            for k,v in pairs(arrItem) do
                print(k, v)
                args1:setObject(CCInteger:create(v), tostring(k))
            end
            args:addObject(args1)
            args:addObject(CCInteger:create(useGold))
        end
        Network.no_loading_rpc(requestFunc, "rewardtask.donateItem", "rewardtask.donateItem", args, true)
    end
    local function rewardtask_refresh()
        if(isLoading)then
            showTip("请求已发送，请等待")
            return
        end
        isLoading = true
        local function requestFunc( cbFlag, dictData, bRet )
            isLoading = false
            if dictData.err == "ok" then
                showTip("悬赏任务刷新成功")
                -- printT(dictData)
                local refresh_num = info.refresh_num
                require "db/DB_Daily_bounty"
                local free_refresh_num = tonumber(DB_Daily_bounty.getDataById(1).free_refresh_times)
                local last_refresh_num = free_refresh_num - refresh_num
                if(last_refresh_num>0)then
                    info.refresh_num = info.refresh_num + 1
                else
                    info.gold_refresh_num = info.gold_refresh_num + 1
                end
                info.task_id = dictData.ret
                info.procedure = 0
                -- printT(info)
                rewardtaskUI(dictData.ret)
            end
        end
        Network.no_loading_rpc(requestFunc, "rewardtask.refresh", "rewardtask.refresh", nil, true)
    end
    local function getFiltersForGood(qualityCpy)
        local filt = {}
        local bagInfo = DataCache.getBagInfo()
        local bagGoodInfo = {}
    
        table.hcopy(bagInfo.treas,bagGoodInfo)
    
        if(not table.isEmpty(bagGoodInfo))then
            for k,v in pairs(bagGoodInfo) do
                if  (tonumber(v.itemDesc.quality) == tonumber(qualityCpy)) and tonumber(v.itemDesc.isExpTreasure) ~= 1  then
                    --过滤升过级的
                    if(tonumber(v.va_item_text.treasureLevel) == 0)then
                        --过滤强化过的
                        if(tonumber(v.va_item_text.treasureDevelop) == -1)then
                            --过滤精炼过的
                            if(tonumber(v.va_item_text.treasureExp) == 0)then
                                --过滤精华宝物
                                if(tonumber(v.itemDesc.item_template_id) ~= 501010)then
                                    if  v.va_item_text and not table.isEmpty(v.va_item_text.treasureInlay)then
                                        --有符印
                                    else
                                        table.insert(filt,v)
                                    end
                                end
                            end
                        end
                    end
                end
                v.isSelected = false
            end
        end
    
        --过滤带有符印的
        -- require "script/ui/refining/RefiningUtils"
        -- local  treasArray = RefiningUtils.getTreasWithoutFuyin(filt)
        local function keySort ( data1, data2 )
          return tonumber(data1.item_template_id) < tonumber(data1.item_template_id)
        end
        table.sort(filt,keySort)
        return filt
    end
    --根据type来确定内容描述
    local function getScriptByType( pType,goal)
        -- local goal = RewardTaskData.getTaskGoal(pId)
        local str = ""
        if(pType == RewardTaskDef.kScriptFuBen)then
            --key_3010
            str = GetLocalizeStringBy("fqq_247")..goal..GetLocalizeStringBy("key_3010")
        elseif pType == RewardTaskDef.kScriptDuoBao then
            str = GetLocalizeStringBy("fqq_248")..goal..GetLocalizeStringBy("key_3010")
        elseif pType == RewardTaskDef.kScriptArena then
            str = GetLocalizeStringBy("fqq_249")..goal..GetLocalizeStringBy("key_3010")
        elseif pType == RewardTaskDef.kScriptLieHun then
            str = GetLocalizeStringBy("fqq_250")..goal..GetLocalizeStringBy("key_3010")
        elseif pType == RewardTaskDef.kScriptQiBao then
            local goalTable = string.split(goal,"|")
            local ms = GetLocalizeStringBy("fqq_283")
            if(tonumber(goalTable[1]) == 4)then
                ms = GetLocalizeStringBy("fqq_284")
            elseif tonumber(goalTable[1]) == 5 then
                ms = GetLocalizeStringBy("fqq_285")
            elseif tonumber(goalTable[1]) == 6 then
                ms = GetLocalizeStringBy("fqq_286")
            elseif tonumber(goalTable[1]) == 7 then
                ms = GetLocalizeStringBy("fqq_287")
            end

            str = GetLocalizeStringBy("fqq_251")..ms..GetLocalizeStringBy("fqq_252")..goalTable[2]..GetLocalizeStringBy("fqq_255")
        elseif pType == RewardTaskDef.kScriptJuXian then
            local goalTable = string.split(goal,"|")
            local rewardInDb = ItemUtil.getItemsDataByStr(goal)
            local icon,itemName,itemColor = ItemUtil.createGoodsIcon(rewardInDb[1],-800,1100,-900,function ( ... )
            end,nil,nil,false)
            str = GetLocalizeStringBy("fqq_251").."“"..itemName.."”"..goalTable[3]..GetLocalizeStringBy("fqq_255")
        elseif pType == RewardTaskDef.kScriptChongZhi then
            str = GetLocalizeStringBy("fqq_254")..goal..GetLocalizeStringBy("key_1447")
        end
        return str
    end
    local function rewardtask_finish()
        local procedure = tonumber(info.procedure)
        local goal = string.split(taskInfo.goal,"|")
        goalNum = tonumber(goal[#goal]) - procedure
        if(goalNum<=0)then
            rewardtask_reward()
            return
        end
        local allTimer = taskInfo.goal
        local lableGo_to = tonumber(taskInfo.type)
        
        if(lableGo_to == RewardTaskDef.kScriptJuXian)then
            --捐赠物品
            local all = string.split(allTimer,"|")
            local findTab = ItemUtil.getCacheItemIdArrByNum( tonumber(all[2]), tonumber(all[3]) )
            local itemNum  = ItemUtil.getCacheItemNumBy(tonumber(all[2]))
            if(itemNum>=tonumber(all[3]))then
                for i,v_itemId in pairs(findTab) do
                    itemArray[tonumber(v_itemId)] = tonumber(all[3])
                end
            else
                local item_data = ItemUtil.getItemById(tonumber(all[2]))
                showTip(item_data.name.."数量不足")
                return
            end
        elseif(lableGo_to == RewardTaskDef.kScriptQiBao)then
            --捐赠宝物
            local all = string.split(allTimer,"|")
            local items = getFiltersForGood(tonumber(all[1])) -- 满足品质的战马列表
            local itemNum  = table.count(items)
            local allTimes = tonumber(all[2])
            if(itemNum>=allTimes)then
                for i=1,allTimes do 
                    itemArray[tonumber(items[i].item_id)] = 1
                end
            else
                showTip(all[1].."星宝物物品数量不足")
                return
            end
        elseif(lableGo_to == RewardTaskDef.kScriptArena)then
            --竞技场
            useItem_stamina(goalNum*2,function()
                arena_challenge_set_num(goalNum, rewardtask_reward)
            end)
            return
        elseif(lableGo_to == RewardTaskDef.kScriptLieHun)then
            --猎魂
            hunt_rapidHunt_unLimit(rewardtask_reward)
            return
        elseif(lableGo_to == RewardTaskDef.kScriptFuBen)then
            --副本
            useItem_energy(goalNum*5,function()
                ncopy_sweep(goalNum,rewardtask_reward)
            end)
            return
        elseif(lableGo_to == RewardTaskDef.kScriptDuoBao)then
            --夺宝
            useItem_stamina(goalNum*2,function()
                fragseize_oneKeySeize(false, rewardtask_reward,goalNum)
            end)
            return
        else
            showTip("悬赏任务类型暂不支持")
            return
        end
        
        printT(itemArray)
        if(not table.isEmpty(itemArray))then
            donateItem(itemArray,0,0)
        end
    end
    rewardtaskUI =  function(task_id)
        require "db/DB_Daily_bounty_id"
        taskInfo = DB_Daily_bounty_id.getDataById(task_id)
        local procedure = tonumber(info.procedure)
        local goal = string.split(taskInfo.goal,"|")
        goalNum = tonumber(goal[#goal]) - procedure
        local refresh_num = info.refresh_num
        require "db/DB_Daily_bounty"
        local free_refresh_num = tonumber(DB_Daily_bounty.getDataById(1).free_refresh_times)
        local last_refresh_num = free_refresh_num - refresh_num
        local rewardtask_refresh_desc = "5/5"
        local rewardtask_refresh_redColorTip = false
        if(last_refresh_num>0)then
            rewardtask_refresh_desc = "免费刷新"..last_refresh_num.."/"..free_refresh_num
        else
            local goldTimes = tonumber(info.gold_refresh_num)
            require "script/ui/rewardtask/RewardTaskData"
            local goldNum = RewardTaskData.getGoldNumByTimes(goldTimes)
            rewardtask_refresh_desc = "消耗金币:"..goldNum
            rewardtask_refresh_redColorTip = true
        end
        local reward = string.split(taskInfo.reward,",")
        local currency = 0
        local advancedCurrency = 0
        for k,v in pairs(reward) do
            local tmp = string.split(v,"|")
            if(tonumber(tmp[1])==34)then
                currency = tonumber(tmp[3])
            elseif(tonumber(tmp[1])==53)then
                advancedCurrency = tonumber(tmp[3])
            end
        end
        local isRefresh = false
        --showTip("任务奖励 悬赏币：".. currency .." 高级悬赏币："..advancedCurrency)
        local min_currency = default_value["reward_task_currency"] or 200
        if(currency<min_currency and advancedCurrency == 0)then
            --刷新
            isRefresh = true
        end
        local gold_cost = 0
        local rewardtask_gold_desc = nil
        local rewardtask_gold_redColorTip = false
        if(taskInfo.gold_cost~=nil)then
            gold_cost = tonumber(taskInfo.gold_cost)
            rewardtask_gold_desc = "消耗金币:"..gold_cost
            rewardtask_gold_redColorTip = true
        end
        local function rewardtask_gold()
            donateItem({},1,gold_cost)
        end

        local allTimer = taskInfo.goal
        local lableGo_to = tonumber(taskInfo.type)
        local canFinish = false
        if(lableGo_to == RewardTaskDef.kScriptJuXian)then
            --捐赠物品
            local all = string.split(allTimer,"|")
            local findTab = ItemUtil.getCacheItemIdArrByNum( tonumber(all[2]), tonumber(all[3]) )
            local itemNum  = ItemUtil.getCacheItemNumBy(tonumber(all[2]))
            procedure = itemNum
            if(itemNum>=tonumber(all[3]))then
                canFinish = true
            end
        elseif(lableGo_to == RewardTaskDef.kScriptQiBao)then
            --捐赠宝物
            local all = string.split(allTimer,"|")
            local items = getFiltersForGood(tonumber(all[1])) -- 满足品质的战马列表
            local itemNum  = table.count(items)
            local allTimes = tonumber(all[2])
            procedure = itemNum
            if(itemNum>=allTimes)then
                canFinish = true
            end
        end
        local rewardtask_finish_desc = procedure.."/"..goal[#goal]
        local rewardtask_finish_redColorTip = true
        if(goalNum<=0 or canFinish)then
            rewardtask_finish_redColorTip = false
        end
        local num = tonumber(info.task_num)
        local taskQuality = tonumber(taskInfo.quality)
        require "script/ui/hero/HeroPublicLua"
        local nameColor = HeroPublicLua.getCCColorByStarLevel(taskQuality)
        local colorText = HeroPublicLua.getColorDesByStarLevel(taskQuality) or ""
        local taskInfoText = {{["text"]="任务数量:"..num.."/12",["color"]=nil},
                              {["text"]="任务品质:"..colorText,["color"]=nameColor},
                              {["text"]=getScriptByType(tonumber(taskInfo.type),taskInfo.goal),["color"]=nil},
                              {["text"]="任务奖励 悬赏币:".. currency .." 高级悬赏币:"..advancedCurrency,["color"]=nil}}
        local buttonFunc = {{["text"]="刷新",["func"]=rewardtask_refresh,["desc"]=rewardtask_refresh_desc,["redColor"]=rewardtask_refresh_redColorTip},
                            {["text"]="手动完成",["func"]=rewardtask_finish,["desc"]=rewardtask_finish_desc,["redColor"]=rewardtask_finish_redColorTip},
                            {["text"]="金币完成",["func"]=rewardtask_gold,["desc"]=rewardtask_gold_desc,["redColor"]=rewardtask_gold_redColorTip}}
        if(taskInfo.gold_cost==nil or canFinish==true)then
            buttonFunc = {{["text"]="刷新",["func"]=rewardtask_refresh,["desc"]=rewardtask_refresh_desc,["redColor"]=rewardtask_refresh_redColorTip},
                          {["text"]="手动完成",["func"]=rewardtask_finish,["desc"]=rewardtask_finish_desc,["redColor"]=rewardtask_finish_redColorTip},}
        end
        if(isRefresh)then
            buttonFunc = {{["text"]="刷新",["func"]=rewardtask_refresh,["desc"]=rewardtask_refresh_desc,["redColor"]=rewardtask_refresh_redColorTip}}
        end
        createTaskUI("悬赏任务",taskInfoText,buttonFunc)
        if(isRefresh)then
            schedule(nil,rewardtask_refresh,0.2)
        end
    end
    local function requestFunc( cbFlag, dictData, bRet )
        if dictData.err == "ok" then
            info = dictData.ret
            local num = tonumber(info.task_num)
            if(num<=0)then
                showTip("悬赏任务剩余次数不足")
                return
            end
            rewardtaskUI(info.task_id)
        end
    end
    rpcCountIndex = rpcCountIndex +1
    Network.no_loading_rpc(requestFunc, "rewardtask.getRewardTask"..rpcCountIndex, "rewardtask.getRewardTask", nil, true)
end

local ncopy_can_atk = {} -- 保存能攻打的副本id
--副本自动战斗
function ncopy_doBattle()
    local getArmyArray = function(baseId,level)
        require "db/DB_Stronghold"
        local sh = DB_Stronghold.getDataById(baseId)
        local levelStr = nil
        if(level==1) then
            levelStr = "simple"
        elseif(level==2) then
            levelStr = "normal"
        elseif(level==3) then
            levelStr = "hard"
        else
            levelStr = "simple"
        end
        local armyIds = nil
        if(level==0) then
            armyIds = sh["npc_army_ids_" .. levelStr]
            if armyIds == nil then
                armyIds = sh["army_ids_" .. levelStr]
            end
        else
            armyIds = sh["army_ids_" .. levelStr]
        end
        local armyIdArray = string.split(armyIds,",")
        return armyIdArray
    end
    local pCopyId = ncopy_can_atk[1].copy_id
    local pBaseId = ncopy_can_atk[1].base_id
    local pLevel = ncopy_can_atk[1].base_lv
    local pArmyIds = getArmyArray(pBaseId,pLevel)
    local armyIndex = 1
    local requestFunc = function( cbFlag, dictData, bRet )
		if dictData.err == "execution" then
            showTip("体力不足停止")
			return
		end
		-- 战斗出错停止
		if dictData.err ~= "ok" then
            showTip("战斗出错停止")
			return
		end
        local info = dictData.ret
        local copy_name = DB_Copy.getDataById(ncopy_can_atk[1].copy_id).name
        local army_name = DB_Stronghold.getDataById(ncopy_can_atk[1].base_id).name
        local star_lv = ncopy_can_atk[1].base_lv
        showTip("攻打副本"..copy_name.." "..army_name.." " .. star_lv.."星 部队" ..armyIndex.." 成功")
		-- 保存战斗数据
        require "script/ui/copy/quickBattle/CopyQuickBattleResultData"
		CopyQuickBattleResultData.addResult(info, ncopy_can_atk[1].base_lv)
		-- 战斗失败停止
		local appraisal = string.upper(info.appraisal)
		if appraisal == "E" or appraisal == "F" then
            showTip("战斗失败停止")
			return
		end

		-- exp
		local expNum = tonumber(info.reward.exp) or 0
		UserModel.addExpValue(expNum)
		-- silver
		local silverNum = tonumber(info.reward.silver) or 0
        UserModel.addSilverNumber(silverNum)
        -- soul
        local soulNum = tonumber(info.reward.soul) or 0
        UserModel.addSoulNum(soulNum)
        --修改体力
        if(tostring(info.newcopyorbase.pass)=="true")then
            UserModel.addEnergyValue(-5)
            -- 刷新副本数据
            require "script/ui/copy/CopyUtil"
            CopyUtil.hanleNewCopyData(info.newcopyorbase)
            schedule(CCDirector:sharedDirector():getRunningScene(),ncopy_getCopyList,0.2)
        elseif(tostring(info.newcopyorbase.pass)=="false")then
            armyIndex = armyIndex + 1
            schedule(CCDirector:sharedDirector():getRunningScene(),ncopy_atk,0.2)
        end
    end
    function ncopy_atk()
        local pArmyId = pArmyIds[armyIndex]
        local pFmtArray = CCDictionary:create()
        require "script/ui/copy/quickBattle/CopyQuickBattleData"
        local pHerolist = CopyQuickBattleData.getBattleHeroList(pArmyId)
        local args = Network.argsHandlerOfTable({pCopyId, pBaseId, pLevel, pArmyId, pHerolist, pHerolist})
        Network.no_loading_rpc(requestFunc, "ncopy.doBattle", "ncopy.doBattle", args, true)
    end
    schedule(CCDirector:sharedDirector():getRunningScene(),ncopy_atk,0.1)
end

--攻打副本
function ncopy_enterBaseLevel()
    showTip("攻打副本")
    local requestFunc = function( cbFlag, dictData, bRet )
        if(dictData.err == "ok") then
            local info = dictData.ret
            ncopy_doBattle()
        elseif(dictData.err == "execution")then
            showTip("没有体力了")
        elseif(dictData.err == "bag")then
            showTip("背包满了")
        elseif(dictData.err == "fake")then
            showTip("请求失败，可能是武将或其他背包满了")
            printT(dictData)
        else
            showTip("未知错误")
            printT(dictData)
        end
    end
    require "script/model/user/UserModel"
	if( 5 > UserModel.getEnergyValue() )then
        local function useItemEnergy(needNum)
            doUseItem_energy(10032,needNum,25)
        end
        creteNumSelectUI(useItemEnergy,10032,0,0,0,"")
		return
	end
    local pCopyId = ncopy_can_atk[1].copy_id
    local pBaseId = ncopy_can_atk[1].base_id
    local pBaseLv = ncopy_can_atk[1].base_lv
    local args = Network.argsHandlerOfTable({pCopyId, pBaseId, pBaseLv})
    Network.no_loading_rpc(requestFunc, "ncopy.enterBaseLevel", "ncopy.enterBaseLevel", args, true)
end
function ncopy_getCopyList()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("查询缓存副本信息")
    require "db/DB_Copy"
    require "db/DB_Stronghold"
    local dictData = DataCache.getNcopyInfo()
    ncopy_can_atk={}
    if(table.isEmpty(dictData))then
        ncopy_can_atk={{["copy_id"]=1,["base_id"]=1001,["base_lv"]=0}}
        ncopy_enterBaseLevel()
        return
    end
    local info = dictData.copy_list
    for k,v in pairs(info) do
        local base_sum = tonumber(DB_Copy.getDataById(v.copy_id).base_sum)
        local allStar = tonumber(DB_Copy.getDataById(v.copy_id).all_stars)
        local per_star = math.floor(allStar/base_sum)
        -- prints(per_star)
        local score = tonumber(v.score)
        if(allStar > score)then
            --0可显示 1可攻击 2npc通关 3简单通关 4普通通关 5困难通关
            for a,b in pairs(v.va_copy_info.progress) do
                local fortDesc = DB_Stronghold.getDataById(tonumber(a))
                local curStar = tonumber(b)
                if(curStar==1)then--可攻击
                    if(fortDesc.npc_army_num_simple and fortDesc.npc_army_num_simple > 0) then
                        table.insert(ncopy_can_atk,{["copy_id"]=tonumber(v.copy_id),["base_id"]=tonumber(a),["base_lv"]=0})
                    else
                        table.insert(ncopy_can_atk,{["copy_id"]=tonumber(v.copy_id),["base_id"]=tonumber(a),["base_lv"]=1})
                    end
                elseif(curStar==2)then--npc通关 不知道是咋算的
                    table.insert(ncopy_can_atk,{["copy_id"]=tonumber(v.copy_id),["base_id"]=tonumber(a),["base_lv"]=1})
                elseif(curStar==3 and per_star>1)then--简单通关
                    table.insert(ncopy_can_atk,{["copy_id"]=tonumber(v.copy_id),["base_id"]=tonumber(a),["base_lv"]=2})
                elseif(curStar==4 and per_star>2)then--普通通关
                    table.insert(ncopy_can_atk,{["copy_id"]=tonumber(v.copy_id),["base_id"]=tonumber(a),["base_lv"]=3})
                elseif(curStar==5 and per_star>3)then--困难通关
                else
                end
            end
        end
    end
    if(table.isEmpty(ncopy_can_atk))then
        showTip("当前没有可以攻打的副本")
        return
    end
    table.sort(ncopy_can_atk,function(a,b)
        return tonumber(a.base_id) < tonumber(b.base_id)
    end)
    table.sort(ncopy_can_atk,function(a,b)
        return tonumber(a.base_lv) > tonumber(b.base_lv)
    end)
    ncopy_enterBaseLevel()
end


local _vipCardInfo={}
--月卡领奖
function monthlycard_getDailyReward()
    showTip("月卡")
    function getDailyReward( pCardId )
        if(finish_table["monthlycard_getDailyReward"..pCardId]==0) then
            return
        end
        local isMonthCardEffect =false
        if(_vipCardInfo[tonumber(pCardId)].due_time == nil)then
            isMonthCardEffect = true
        end
        if( not table.isEmpty( _vipCardInfo[tonumber(pCardId)].va_card_info) and  tonumber( _vipCardInfo[tonumber(pCardId)].due_time)> BTUtil:getSvrTimeInterval() ) then
        else
            isMonthCardEffect = true
        end
        if(isMonthCardEffect)then
            showTip("月卡"..pCardId.."已过期，请重新购买")
            return
        end
        local isGet = true
        if(_vipCardInfo[tonumber(pCardId)].due_time == nil)then
            isGet = true
        end
        require "script/ui/rechargeActive/ActiveCache"
        if( ActiveCache.isToday( tonumber( _vipCardInfo[tonumber(pCardId)].va_card_info.monthly_card.reward_time))) then
        else
            isGet = false
        end
        if(isGet)then
            showTip("月卡"..pCardId.."已领取，请勿重新领取")
            finish_table["monthlycard_getDailyReward"..pCardId] = 1
            return
        end
        require "db/DB_Vip_card"
        local vipCardData = DB_Vip_card.getDataById(pCardId)
        local items= ItemUtil.getItemsDataByStr( vipCardData.cardReward)
        local function callbcak( cbFlag, dictData, bRet )
            if(bRet == true) then
                showTip("领取月卡"..pCardId.."成功")
                ItemUtil.addRewardByTable(items)
                finish_table["monthlycard_getDailyReward"..pCardId] = 1
            end
        end

        
        local hasHero= false
        local hasItem= false
    
        -- 判断是否有hero
        for i=1, #items do
            if(items[i].type== "hero" ) then
                hasHero=true
                break
            end
        end
        -- 判断是否有item
        for i=1, #items do
            if(items[i].type== "item" ) then
                hasItem=true
                break
            end
        end
        require "script/ui/hero/HeroPublicUI"
        require "script/ui/item/ItemUtil"
        if( hasHero and HeroPublicUI.showHeroIsLimitedUI() ) then
        elseif( hasItem and isBagFull() )then
        else
            local args = CCArray:create()
            args:addObject(CCInteger:create(pCardId))
            Network.no_loading_rpc(callbcak, "monthlycard.getDailyReward", "monthlycard.getDailyReward", args, true)
        end
    end
    local function requestFunc( cbFlag, dictData, bRet )
		if(bRet == true) then
            for k,v in pairs(dictData.ret) do
                _vipCardInfo[tonumber(k)] = v
            end
            -- printT(dictData.ret)
            -- if(1)then return end
            for id=1,3 do--月卡id:1~3
                local v =_vipCardInfo[id]
                if(v.due_time==nil or tonumber(v.due_time)<TimeUtil.getSvrTimeByOffset(0))then
                    showTip("当前没有激活月卡"..id.."或已过期")
                    finish_table["monthlycard_getDailyReward"..id]=1
                else
                    local function _getDailyReward()
                        getDailyReward(id)
                    end
                    schedule(nil,_getDailyReward,id*0.3)
                end
            end
		end
	end
	rpcCountIndex = rpcCountIndex +1
	Network.no_loading_rpc(requestFunc, "monthlycard.getCardInfo"..rpcCountIndex, "monthlycard.getCardInfo", nil, true)
end

--贮金
function zhujin()
    if(not ActivityConfigUtil.isActivityOpen("annivSixth"))then
        showTip("当前不在贮金活动时间")
        return
    end
    if(finish_table["zhujin"]==1)then
        showTip("今日贮金活动已完成或已领取")
        return
    end
    showTip("贮金")
    local dbData = ActivityConfigUtil.getDataByKey("annivSixth").data[1]
    local task = ActivityConfigUtil.getDataByKey("annivSixthTask").data
    local addGoldNum = 0
    -- printT(dbData)
    -- printT(task)
    -- if(1)then return end
    local function getInfo()
        showTip("获取贮金信息")
        local requestFunc = function(cbFlag,dictData,bRet)
            if dictData.err == "ok" then
                printT(dictData)
                if(isTwoStart())then
                    -- showTip("第二阶段领取金币")
                    local allKeepNum = tonumber(dictData.ret.deposit) or 0
                    local lastDay = tonumber(dbData.step_2) or 1
                    addGoldNum = math.ceil(allKeepNum/lastDay)
                    local dayNum = TimeUtil.getDifferDay(getTwoStartTime())+1
                    local isGet = {}
                    for k,v in pairs(dictData.ret.day_reward) do
                        if tonumber(v)<=dayNum then
                            isGet[tostring(v)] = 1
                            break
                        end
                    end
                    if(table.count(isGet)==dayNum)then
                        showTip("贮金已领取今日奖励")
                        finish_table["zhujin"]=1
                        return
                    end
                    for i=1,dayNum do
                        if(isGet[tostring(i)]~=1)then
                            local function _recvDailyReward()
                                recvDailyReward(i)
                            end
                            schedule(nil,_recvDailyReward,i*0.2)
                        end
                    end
                    
                    return 
                end
                -- printT(dictData)
                for k,v in pairs(dictData.ret.task) do
                    if(task[tonumber(k)]~=nil and tonumber(v)>=tonumber(task[tonumber(k)].finish))then
                        task[tonumber(k)].is_finish = 1
                        task[tonumber(k)].is_get = 0
                        task[tonumber(k)].progress = tonumber(v)
                    elseif(task[tonumber(k)]~=nil)then
                        task[tonumber(k)].is_finish = 0
                        task[tonumber(k)].is_get = 0
                        task[tonumber(k)].progress = tonumber(v)
                    end
                end
                -- printT(task)
                -- printT(dictData.ret.reward)
                for k,v in pairs(dictData.ret.reward) do
                    if(task[tonumber(v)]~=nil)then
                        -- showTip(v)
                        task[tonumber(v)].is_get = 1
                    end
                end
                -- printT(task)
                for k,v in pairs(task)do
                    if(v.is_get~=1 and tonumber(v.id)~=7 and tonumber(v.id)~=6)then
                        finish_task()
                        return
                    end
                end
                finish_table["zhujin"]=1
                showTip("贮金任务已完成")
                return
            end
        end
        Network.no_loading_rpc(requestFunc,"annivsixth.getInfo","annivsixth.getInfo",nil,true)
    end
    --  领取任务奖励
    local function recvTaskReward(pTaskId)
        if(task[pTaskId].is_get==1)then
            showTip("任务“"..task[pTaskId].task_des .. "”已领取")
            for k,v in pairs(task)do
                if(v.is_get==0)then
                    schedule(nil,finish_task,0.2)
                    return
                end
            end
            finish_table["zhujin"]=1
            return 
        end
        local requestFunc = function(cbFlag,dictData,bRet)
            if dictData.err == "ok" then
                showTip("任务“"..task[pTaskId].task_des .. "”已完成")
                task[pTaskId].is_get = 1
                for k,v in pairs(task)do
                    if(v.is_get==0)then
                        schedule(nil,finish_task,0.2)
                        return
                    end
                end
                finish_table["zhujin"]=1
            end
        end
        local args = Network.argsHandlerOfTable({pTaskId})
        Network.no_loading_rpc(requestFunc,"annivsixth.recvTaskReward","annivsixth.recvTaskReward",args,true)
    end
    --  完成任务，先一键扫荡，再运行贮金做任务
    function finish_task()
        showTip("完成贮金任务")
        local n=0
        for k,v in pairs(task)do
            if(v.is_get~=1)then
                if(v.is_finish~=1)then
                    n=n+1
                    if(tonumber(v.id)==1)then--每日花费1000金币
                        showTip("请再消费".. tonumber(v.finish)-v.progress .."金币")
                        n=n-1
                        -- return
                    elseif(tonumber(v.id)==2)then--每日花费1000万银币
                        hunt_rapidHunt_unLimit(function()
                            recvTaskReward(tonumber(v.id))
                        end)
                        return
                    elseif(tonumber(v.id)==3)then--每日花费300点体力
                        ncopy_sweep(math.ceil((tonumber(v.finish)-v.progress)/5),function()
                            recvTaskReward(tonumber(v.id))
                        end)
                        return
                    elseif(tonumber(v.id)==4)then--每日花费200点耐力
                        arena_challenge_set_num(math.ceil((tonumber(v.finish)-v.progress)/2),function()
                            recvTaskReward(tonumber(v.id))
                        end)
                        return
                    elseif(tonumber(v.id)==5)then--每日任务积分达到100积分
                    elseif(tonumber(v.id)==6)then--每日领取月卡
                    elseif(tonumber(v.id)==7)then--每日领取超值月卡
                    elseif(tonumber(v.id)==8)then--每日为10个好友赠送耐力
                    elseif(tonumber(v.id)==9)then--每日挑战军团副本1次
                    elseif(tonumber(v.id)==10)then--每日军团贡献1次
                    end
                else
                    recvTaskReward(tonumber(v.id))
                    return
                end
            end
        end
        -- if(n>0)then
        --     schedule(nil,finish_task,0.2)
        -- end
    end
    --  领取每日奖励
    function recvDailyReward(pDay)
        local requestFunc = function(cbFlag,dictData,bRet)
            if dictData.err == "ok" then
                showTip("成功领取第"..pDay.."天的奖励"..addGoldNum.."金币")
                UserModel.addGoldNumber(addGoldNum)
                finish_table["zhujin"]=1
            end
        end
        local args = Network.argsHandlerOfTable({pDay})
        Network.no_loading_rpc(requestFunc,"annivsixth.recvDailyReward","annivsixth.recvDailyReward",args,true)
    end
    --第二阶段是否开启
    function getTwoStartTime()
        local startTime = tonumber(ActivityConfigUtil.getDataByKey("annivSixth").start_time)
        local dbData = ActivityConfigUtil.getDataByKey("annivSixth").data[1]
        local lastDay = tonumber(dbData.step_1) or 0
        local endTime = startTime + lastDay*24*60*60
        return endTime
    end
    function isTwoStart()
        local endTime = getTwoStartTime()
        local curTime = TimeUtil.getSvrTimeByOffset()
        if(curTime>endTime)then
            return true
        else
            return false
        end
    end
    getInfo()
end

function startRequestRefershData()
    showTip("更新数据")
    -- require "script/utils/TimerRequestCenter"
    -- TimerRequestCenter.startRequest()
    require "script/network/PreRequest"
    PreRequest.startPreRequest()
end

--更新体耐力值
function updateUserInfo()
    -- 得到用户信息
    showTip("更新用户信息（体耐力值等）")
    local function fnGetUser(cbName, dictData, bRet)
        if (bRet) then
            require "script/model/user/UserModel"
            local b_userinfo = dictData.ret
            local pos, stop = string.find(b_userinfo.uname, " ")
            if(pos ~= nil and pos == 1)then
                local b_64str = string.gsub(b_userinfo.uname, " ", "")
                if g_system_type == kBT_PLATFORM_IOS or g_system_type == kBT_PLATFORM_ANDROID then
                    b_userinfo.uname = Base64.decode(b_64str)
                else
                    b_userinfo.uname = CCCrypto:decodeBase64(b_64str)
                end
            end
            UserModel.setUserInfo(b_userinfo)
            require "script/ui/main/MainScene"
		    MainScene.updateAvatarInfo()
            MainScene.updateInfoData()
            MainScene.updateEnergyValueUI()
            MainScene.updateStaminaValueUI()
            showTip("更新用户信息成功")
        end
    end
    Network.no_loading_rpc(fnGetUser, "user.getUser","user.getUser", nil, true)
end


--城池争夺奖励
function citywar_getReward()
        --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    local guild_id = 0
    local cityId = 0
    local cityInfoPass = {}
    showTip("城池占领奖励")

    local callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            -- printT(dictData)
            require "script/ui/guild/city/CityData"
            local xiShu = CityData.getXiShuByMemberType(dictData.ret.member_type)
            -- 表配置奖励数据
            local thisCityBaseData = CityData.getDataById(cityId)
            local rewardData = ItemUtil.getItemsDataByStr( thisCityBaseData.baseReward )
            for k,v in pairs(rewardData) do
                -- 真实数据 表配置基础值*系数 向下取整
                v.num = math.floor(v.num * xiShu)
            end
            ItemUtil.addRewardByTable(rewardData)
            showTip("城池占领奖励领取成功")
            finish_table["citywar_getReward"] = 1
        else
            printT(dictData)
            showTip("请求失败，请检查背包，如果不是由于背包满了的原因，请打开SweepAll.lua文件中的脚本网址联系作者")
        end
    end
    local function citywar_getCityInfo(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            -- printT(dictData)
            -- 该城市是否可以领奖
            local rewardCity = cityInfoPass.reward
            prints(cityId..","..rewardCity)
            if( rewardCity and tonumber(rewardCity) >0 and tonumber(rewardCity) == cityId )then
                local args = CCArray:create()
                args:addObject(CCInteger:create(tonumber(cityId)))
                Network.no_loading_rpc(callback, "citywar.getReward", "citywar.getReward", args, true)
            else
                showTip("城池占领奖励，请勿重复签到")
                finish_table["citywar_getReward"] = 1
                return
            end
        end
    end
    local requestFunc = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            cityInfoPass = dictData.ret
            -- printT(dictData)
            
            for k,v in pairs(dictData.ret.occupy) do
                if(tonumber(v.guild_id)==guild_id)then
                    -- showTip(k)
                    cityId = tonumber(k)
                    break
                end
            end
            if(cityId==0)then
                showTip("您的军团没有占领城池")
                return
            end
            local args = CCArray:create()
            args:addObject(CCInteger:create(tonumber(cityId)))
            Network.no_loading_rpc(citywar_getCityInfo, "citywar.getCityInfo", "citywar.getCityInfo", args, true)
        end
    end
    local guild_callback = function(cbFlag, dictData, bRet)
        if (dictData.err == "ok") then
            guild_id = tonumber(dictData.ret.guild_id) or 0
            local tempArgs = CCArray:create()
            tempArgs:addObject(CCInteger:create(guild_id))
            Network.no_loading_rpc(requestFunc, "citywar.getGuildSignupList", "citywar.getGuildSignupList", tempArgs, true)
        end
    end
    Network.no_loading_rpc(guild_callback, "guild.getMemberInfo", "guild.getMemberInfo", nil, true)
end

--过关斩将
function pass_enter()
    if(TimeUtil.getSvrTimeByOffset()<TimeUtil.getIntervalByTime("040000"))then
        showTip("过关斩将未到时间")
        return
    end
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    -- if(finish_table["pass_enter"]==1)then
    --     showTip("今日过关斩将已完成")
    --     return
    -- end
    showTip("过关斩将")
    local lose_num = 0
    local buy_num = 0
    local info={}
    local battle_result = {}
    local opponent_info = {}
    finish_table["pass_enter"]=1
    --买宝箱信息
    local function buyChestInfo()
        showTip("过关斩将购买宝箱")
        -- body
        local buy_num = default_value["pass_dealChest"] or 1
        local function requestFunc( cbFlag, dictData, bRet )
            -- printT(dictData.ret)
            -- prints(cbFlag)
            if(bRet == true)then
                -- local dataRet = dictData.ret
                showTip("购买宝箱"..tostring(buy_num).."次")
                finish_table["pass_enter"]=1
            end
        end
        
        if(tonumber(info.luxurybox_num)>=buy_num)then
            buy_num=0
            showTip("已达到指定购买次数")
            return
        else
            buy_num = buy_num - tonumber(info.luxurybox_num)
        end
        local args = CCArray:create()
        args:addObject(CCInteger:create(tonumber(info.cur_base)))
        args:addObject(CCInteger:create(1))--0免费的一次，没有第三个参数，1付费，第三个参数为购买次数
        args:addObject(CCInteger:create(buy_num))
        Network.no_loading_rpc(requestFunc, "pass.dealChest", "pass.dealChest", args, true)
    end

    --宝箱奖励
    local function rewardInfo()
        showTip("过关斩将领取免费宝箱")
        -- body
        local function requestFunc( cbFlag, dictData, bRet )
            if(dictData.err == "ok")then
                local dataRet = dictData.ret
                showTip("领取免费宝箱成功")
                schedule(nil,buyChestInfo,0.2)
            end
        end
        -- local buy_num = default_value["pass.dealChest"] or 1
        local args = CCArray:create()
        args:addObject(CCInteger:create(tonumber(info.cur_base)))
        args:addObject(CCInteger:create(0))--0免费的一次，没有第三个参数，1付费，第三个参数为购买次数
        -- args:addObject(CCInteger:create(buy_num))
        Network.no_loading_rpc(requestFunc, "pass.dealChest", "pass.dealChest", args, true)
    end
    local function attack( p_tag )
        showTip("过关斩将攻打"..p_tag.."星敌人")
        -- body
        local function requestFunc( cbFlag, dictData, bRet )
            if(bRet == true)then
                if(string.upper(dictData.ret.appraisal)=="F" or string.upper(dictData.ret.appraisal)=="E")then
                    showTip("过关斩将挑战失败")
                    AlertTip.showAlert("是否消耗所有耐力夺宝", nil, true, nil)
                    -- showAlert("过关斩将挑战失败,请手动攻打")
                    stopSweep()
                else
                    info.pass_num = tonumber(info.pass_num)+1
                    schedule(nil,rewardInfo,0.2)
                end
                -- printT(dictData)
            end
        end
        local args = CCArray:create()
        local args1 = CCArray:create()
        args:addObject(CCInteger:create(tonumber(info.cur_base)))
        args:addObject(CCInteger:create(tonumber(p_tag)))--难度1~3
        args:addObject(args1)
        Network.no_loading_rpc(requestFunc, "pass.attack", "pass.attack", args, true)
    end

    local function getAppraisal(str)
        local score=0
        if(string.upper(str)=="SSS")then
            score= 9
        elseif(string.upper(str)=="SS")then
            score= 8
        elseif(string.upper(str)=="S")then
            score= 7
        elseif(string.upper(str)=="A")then
            score= 6
        elseif(string.upper(str)=="B")then
            score= 5
        elseif(string.upper(str)=="C")then
            score= 4
        elseif(string.upper(str)=="D")then
            score= 3
        elseif(string.upper(str)=="E")then
            score= 2
        elseif(string.upper(str)=="F")then
            score= 1
        else
            showTip("需要更新战斗评价转换")
        end
        return score
    end
    --战斗信息
    local function fightRankChallenge(pUid,pIndex)
        showTip("敌人uid:"..pUid)
        local function requestFunc( cbFlag, dictData, bRet )
            -- printT(dictData)
            -- printT(cbFlag)
            if(dictData.err == "ok")then
                local max_score = 0
                local max_index = 0
                battle_result[tostring(pIndex)]=getAppraisal(dictData.ret.appraisal)
                -- printT(battle_result)
                if(table.count(battle_result)==3)then
                    for k,v in pairs(battle_result)do
                        if(v>=max_score)then
                            max_score= v
                            max_index = tonumber(k)
                        end
                    end
                    showTip("攻打"..max_index.."阶敌人")
                    attack(max_index)
                else
                    for i=1,3 do
                        if(battle_result[tostring(i)]==nil)then
                            local function _fightRankChallenge()
                                fightRankChallenge(opponent_info[tostring(i)].uid,i)
                            end
                            schedule(nil,_fightRankChallenge,0.3)
                            break
                        end
                    end
                end
                
            end
        end
        local args = CCArray:create()
        args:addObject(CCInteger:create(pUid))
        Network.no_loading_rpc(requestFunc, "user.fight", "user.fight", args, true)
    end

    --对手信息
    local function getOpponentList()
        showTip("过关斩将获取敌人列表")
        local function requestFunc( cbFlag, dictData, bRet )
            if(bRet == true)then
                local dataRet = dictData.ret
                opponent_info = dataRet
                -- printT(opponent_info)
                for k,v in pairs(dataRet)do
                    fightRankChallenge(v.uid,tonumber(k))
                    break
                end
            else
                printT(dictData)
            end
        end
        local args = CCArray:create()
        args:addObject(CCInteger:create(tonumber(info.cur_base)))
        --调用获取对手命令
        Network.no_loading_rpc(requestFunc, "pass.getOpponentList", "pass.getOpponentList", args, true)
    end

    --扫荡
    local function sweep( )
        showTip("过关斩将扫荡")
        -- body
        local function requestFunc( cbFlag, dictData, bRet )
            if(bRet == true)then
                -- printT(dictData)
                info.pass_num = math.floor(info.va_pass.sweepInfo.count*0.99)
                info.cur_base = math.floor(info.va_pass.sweepInfo.count*0.99)+1
                getOpponentList()
            end
        end
        local box_num = default_value["pass_sweep"] or 1
        local args = CCArray:create()
        args:addObject(CCInteger:create(box_num))--购买几次宝箱
        args:addObject(CCInteger:create(1))--是否花星星购买属性
        Network.no_loading_rpc(requestFunc, "pass.sweep", "pass.sweep",args, true)
    end
    --获取神兵副本信息
    function getCopyInfo( )
        showTip("过关斩将获取信息")
        local function requestFunc( cbFlag, dictData, bRet )
            if(bRet == true)then
                local dataRet = dictData.ret
                info = dataRet
                printT(dictData)
                if dataRet and dataRet.lose_num then
                    lose_num=tonumber(dataRet.lose_num)
                end
                if dataRet and dataRet.buy_num then
                    buy_num=tonumber(dataRet.buy_num)
                end
                if(tonumber(dataRet.va_pass.sweepInfo.count)<15)then
                    showTip("过关斩将未通关，请手动通关后进行扫荡")
                    return
                end
                if(tonumber(dataRet.pass_num)<=1 and tonumber(dataRet.cur_base) == 1)then
                    --扫荡
                    sweep()
                elseif(tonumber(dataRet.pass_num)==15 and tonumber(dataRet.cur_base) == 15)then
                    local buyNum = default_value["pass_dealChest"] or 1
                    if(dataRet.va_pass.chestShow )then
                        if(dataRet.va_pass.chestShow.freeChest)then
                            if(tonumber(dataRet.va_pass.chestShow.freeChest)==0)then
                                rewardInfo()
                                return
                            else
                                buyChestInfo()
                                return
                            end
                        end
                    end
                    showTip("今日过关斩将已攻打，请勿重复操作")
                    finish_table["pass_enter"]=1
                else
                    showTip("今日过关斩将无法扫荡，尝试攻打中")
                    getOpponentList()
                end
            end
        end
        Network.no_loading_rpc(requestFunc, "pass.enter", "pass.enter", nil, true)
    end
    getCopyInfo()
end

--邸报，所有人都可以领取，网站固定 http://sg.zuiyouxi.com/act/sign?v=203223，最后6为随机数字
function web_dibao()
    if(finish_table["web_dibao"]==1)then
        showTip("今日邸报已签到")
        return
    end
    require "script/ui/web/WebViewModel"
    function getWebActionArray()
        local WebActionArray = {
            ["noticear"] = {
                [1] = {
                    ["type"] = 0,
                    ["content"] = "http://sg.zuiyouxi.com/act/active",
                    ["extended_one"] = {
                    },
                    ["autoPop"] = 1,
                },
            },
        }
        return WebViewModel.getWebActionArray() or WebActionArray
    end
    --展示默认的官网
    function getOfficeViewUrl( ... )
        local url = "http://sg.zuiyouxi.com"
        return url
    end
    --展示webview
    function getWebViewUrl(p_limit )
        local taegeturl = ""
        local limit = p_limit or isLimitShow()
        if(not limit)then
            -- return getOfficeViewUrl()
            taegeturl = "http://sg.zuiyouxi.com/act/active"
        end
        local json = getWebActionArray()
        if(not json or not json.noticear or not json.noticear[1] or not json.noticear[1].content)then
        else 
            taegeturl = json.noticear[1].content
        end
        if(taegeturl == nil or taegeturl == "")then
            -- return getOfficeViewUrl()
            taegeturl = "http://sg.zuiyouxi.com/act/active"
        end
        local index = string.find(taegeturl, "?")
        if not index then
            taegeturl = taegeturl.."?"
        else
            taegeturl = taegeturl.."&"
        end
        local serid = UserModel.getServerId()
        local uidStr = UserModel.getUserUid()
        require "script/ui/login/LoginScene"
        if(LoginScene.getFeignRoleId ~=nil and LoginScene.getFeignRoleId() ~= nil)then
            uidStr = LoginScene.getFeignRoleId()
        end
        local url = taegeturl .."login_name="..uidStr.."&groupid="..serid.."&qid=".. Platform.getPid() .."&uuid="..g_dev_udid.."&time="..TimeUtil.getSvrTimeByOffset()--.."serverKey=".. serid ..Platform.getUrlParam().. "&reserve01=".."".."&reserve02="..""--.."login_name="..UserModel.getUserUid().."&groupid="..serid.."&qid=".. Platform.getPid() .."&uuid="..g_dev_udid.."&time="..TimeUtil.getSvrTimeByOffset()
        local dealUrl = "groupid="..serid.."login_name="..uidStr.."qid=".. Platform.getPid() .."time="..TimeUtil.getSvrTimeByOffset().."uuid="..g_dev_udid
        local sortedParams = dealUrl .. "9c98948d313ccdAE962e899a60692c_russia"
        local sign = BTUtil:getMd5SumByString(sortedParams)
        local returl = url .. "&sign=" .. sign
        return returl
        -- Platform.openCustomWebView(returl,g_winSize.width, g_winSize.height,0,0)
    end
    
    -- 判断玩家有没有达到看到webview的条件
    function isLimitShow( ... )
        local json = getWebActionArray()
        if(not json or not json.noticear or not json.noticear[1] or not json.noticear[1].extended_one)then
            return false
        end
        -- if(not json.noticear[1].extended_one)then
        -- 	return true
        -- end
        local extended_one = json.noticear[1].extended_one
        local lvFlag = true
        local vipFlag = true
        if(extended_one.lv)then
            local userLv = UserModel.getHeroLevel()
            if(userLv >= tonumber(extended_one.lv.begin)  and userLv <= tonumber(extended_one.lv["end"]))then
                lvFlag = true
            else
                lvFlag = false
            end
        end
        if(extended_one.vip)then
            local userLv = UserModel.getVipLevel()
            if(userLv >= tonumber(extended_one.vip.begin)  and userLv <= tonumber(extended_one.vip["end"]))then
                vipFlag = true
            else
                vipFlag = false
            end
        end
        if(lvFlag and vipFlag)then
            return true
        end
        return false
    end
    local activityUrl = getWebViewUrl()
    -- showTip(actUrl)
    local httpClent = CCHttpRequest:open(activityUrl, kHttpGet)
    httpClent:sendWithHandler(function(res, hnd)
        -- showTip("ResponseCode："..res:getResponseCode())
		if(res:getResponseCode()~=200)then
        	showTip("邸报请求失败")
        	return
    	else
            local iter = string.gmatch(tostring(res:getResponseData()),"<a href=\"([^%s]+)\">")
            local url="/act/sign?v="..math.random(100000,999999)
            for k, _ in iter do
                -- showTip(k)
                if(string.find(tostring(k),"sign"))then
                    url = tostring(k)
                    break
                end
            end
            local actUrl = getOfficeViewUrl()..url
            -- prints(signtUrl)
            local checkTodaySignUrl = "https://sg.zuiyouxi.com/act/sign/checkTodaySign?v="..math.random()
            local getSignNumUrl = "http://sg.zuiyouxi.com/act/sign/getSignNum?v="..math.random()
            local signUrl = "http://sg.zuiyouxi.com/act/sign/doSign?v="..math.random()
        
        
            local function getSignNum(msg)
                local httpClent = CCHttpRequest:open(getSignNumUrl, kHttpGet)
                httpClent:sendWithHandler(function(res, hnd)
                    -- showTip("ResponseCode："..res:getResponseCode())
                    if(res:getResponseCode()~=200)then
                        showTip("邸报获取签到天数请求失败")
                        return
                    else
                        local cjson = require("cjson")
                        local json = cjson.decode(res:getResponseData())
                        showTip(msg.."\n恭喜您，已累计签到".. json.num .. "天。")
                    end
                end)
            end
            local function sign()
                local httpClent = CCHttpRequest:open(signUrl, kHttpGet, nil)
                httpClent:sendWithHandler(function(res, hnd)
                    -- showTip("ResponseCode："..res:getResponseCode())
                    if(res:getResponseCode()~=200)then
                        showTip("邸报签到请求失败")
                        return
                    else
                        local cjson = require("cjson")
                        local json = cjson.decode(res:getResponseData())
                        -- showTip(json.msg)
                        finish_table["web_dibao"]=1
                        getSignNum(json.msg)
                    end
                end)
            end
            local function checkTodaySign()
                local httpClent = CCHttpRequest:open(checkTodaySignUrl, kHttpGet)
                httpClent:sendWithHandler(function(res, hnd)
                    -- showTip("ResponseCode："..res:getResponseCode())
                    if(res:getResponseCode()~=200)then
                        showTip("邸报获取今日签到情况请求失败")
                        return
                    else
                        local cjson = require("cjson")
                        local json = cjson.decode(res:getResponseData())
                        -- prints(tostring(res:getResponseData()))
                        -- printT(json)
                        if(json.error==1)then--没登录
                            showTip(json.msg)
                        elseif(json.error==2)then--已签到
                            -- showTip(json.msg)
                            finish_table["web_dibao"]=1
                            getSignNum(json.msg)
                        else
                            sign()
                        end
                    end
                end)
            end
            local function login()
                local httpClent = CCHttpRequest:open(actUrl, kHttpGet)
                httpClent:sendWithHandler(function(res, hnd)
                    -- showTip("ResponseCode："..res:getResponseCode())
                    if(res:getResponseCode()~=200)then
                        showTip("邸报登录请求失败")
                        return
                    else
                        checkTodaySign()
                    end
                end)
            end
            login()
		end
	end)
end

--节日狂欢，点将台任务（七星台，铜雀台，名将台，后军台，神器台）
function festivalActReward_DianJiangTai()
    readDefaultValue(false)
    if(default_value["festivalActReward_DianJiangTai"]~=1)then
        return
    end
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("节日狂欢点将台任务")
    if(not isFestivalActOpen())then
        showTip("当前不在节日狂欢活动期间")
        finish_table["festivalActReward_DianJiangTai"] = 1
        return
    end
    local record_table = {}
    local task_table = {
        ["七星台"]={["id"]=2,["func"]=sevenslottery_lottery},["神器台"]={["id"]=4,["func"]=godbless_bless},
        ["普通名将"]={["id"]=5,["func"]=forfmhero_draw},["高级名将"]={["id"]=6,["func"]=forfmherobt_draw},
        ["铜雀台"]={["id"]=7,["func"]=tongque_lottery},["后军台"]={["id"]=8,["func"]=houjunfactory_lottery}}
    local function taskReward(id,desc)
        local function requestFunc( cbFlag, dictData, bRet )
            if dictData.err == "ok" then
                showTip("节日狂欢,"..desc..",领奖成功")
            else
                showTip("节日狂欢,"..desc..",领奖失败")
            end
        end
        
        local args = CCArray:create()
        args:addObject(CCInteger:create(id))
        Network.no_loading_rpc(requestFunc, "festivalact.taskReward", "festivalact.taskReward", args, true)
    end
    local function finish_callback(id,desc,isFinish)
        if(isFinish)then -- 已经完成的任务会返回true,因为等级没达到或当前时间未开放等导致的未完成会返回false
            taskReward(id,desc)
        end
        table.insert(record_table,id)
        if(table.count(record_table)==table.count(task_table))then
            showTip("狂欢七星台、后军台等任务已完成")
            finish_table["festivalActReward_DianJiangTai"] = 1
        end
    end
    local function requestFunc(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local info = dictData.ret
            local PseasonNum = tonumber(info.period) -- 当前是第几季
            local curDay = tonumber(info.day) -- 当前是活动第几天
            local festivalAct = ActivityConfigUtil.getDataByKey("festivalAct").data
            local festivalActReward = ActivityConfigUtil.getDataByKey("festivalActReward").data
            local startTime = tonumber(ActivityConfigUtil.getDataByKey("festivalAct").start_time)
            local endTime = tonumber(ActivityConfigUtil.getDataByKey("festivalAct").end_time)
            local periodStartTime = TimeUtil.getIntervalByTimeDesString(festivalAct[PseasonNum].start_time)
            local periodEndTime = TimeUtil.getIntervalByTimeDesString(festivalAct[PseasonNum].end_time)
            local periodDayNum = math.ceil((periodEndTime - periodStartTime)/86400)--当前季总天数
            local dayNum = math.ceil((endTime - startTime)/86400)-1 --活动总天数
            local taskList2 = festivalAct[PseasonNum].mission_2
            local taskInfo = info.data[tostring(PseasonNum)]["1"]
            --112001 七星台   112002 第二期
            --114001 神器台   114002
            --115001 普通名将 115002
            --116001 高级名将 116002
            --117001 铜雀台   117002
            --118001 后军台   118002
            if(curDay ~= periodDayNum and curDay~=dayNum)then
                showTip("当前不是狂欢最后一天")
                return
            end
            local function need_num(id)
                local goalNum = tonumber(festivalActReward[id].finish) -- 目标次数
                local finishNum = tonumber(taskInfo[tostring(id)][1]) -- 已完成次数
                return goalNum - finishNum
            end

            local n = 0
            for k,v in pairs(task_table) do
                local id = 110000+v.id*1000+PseasonNum
                local needNum = need_num(id)
                if(needNum<=0)then
                else
                    showTip(k.."抽卡"..needNum.."次")
                    local function set_num_callback()
                        v.func(needNum,true,function(isFinish)
                            finish_callback(id,festivalActReward[id].desc,isFinish)
                        end)
                    end
                    schedule(nil,set_num_callback,n*0.5)
                    n = n + 1
                end
            end
            if(n<=0)then
                showTip("狂欢七星台、后军台等任务已完成")
                finish_table["festivalActReward_DianJiangTai"] = 1
            end
        end
    end
    rpcCountIndex = rpcCountIndex +1
    Network.no_loading_rpc(requestFunc, "festivalact.getInfo"..rpcCountIndex, "festivalact.getInfo", nil, true)
end

function compete_contest(setNum,callbackFunc)
    local curTime = TimeUtil.getSvrTimeByOffset()
    if(curTime<=TimeUtil.getIntervalByTime("080000") or curTime>=TimeUtil.getIntervalByTime("230000"))then
        showTip("当前时间比武无法攻打")
        return
    end
    if(getWeekNum()==7)then
        showTip("当前时间比武无法攻打")
        return
    end
    --背包是否满
    if isBagFull(true) then
        showTip("背包满了")
        stopSweep()
        return
    end
    showTip("比武")
    -- 得到比武数据
    local rivalList = {}
    local atkFailUids = {}--打不过的uid
    local refresh = 0
    local num = 0
    local setNum = tonumber(setNum) or 0
    --战斗信息
    local function fightRankChallenge(pIndex)
        local function requestFunc( cbFlag, dictData, bRet )
            if(dictData.err == "ok")then
                if(string.find(string.upper(dictData.ret.appraisal),"SSS"))then
                    contestMany(rivalList[pIndex].uid, 0, num, 1)
                else
                    table.insert(atkFailUids,rivalList[pIndex].uid)
                    if(pIndex>=#rivalList)then
                        rivalList={}
                        schedule(nil,refreshRivalList,0.2)
                        return
                    end
                    schedule(nil,function() fightRankChallenge(pIndex+1) end,0.2)
                    return
                end
                
            end
        end
        local args = CCArray:create()
        args:addObject(CCInteger:create(rivalList[pIndex].uid))
        Network.no_loading_rpc(requestFunc, "user.fight", "user.fight", args, true)
    end
    function getCompeteInfo(  )
        showTip("获取比武信息")
        local function requestFunc( cbFlag, dictData, bRet )
            prints("getContestInfo---后端数据")
            -- printT( dictData)
            if(bRet == true)then
                -- print_t(dictData.ret)
                local dataRet = dictData.ret
                local buyNum = tonumber(dataRet.buy)
                local atkNum = tonumber(dataRet.num)
                require "script/ui/match/MatchData"
                local freeNum = MatchData.getAllContestNum()
                num = freeNum - atkNum + buyNum
                if(num<setNum)then
                    schedule(nil,function() buyCompeteNum(setNum-num) end,0.2)
                    return
                else
                    num = setNum
                end
                refresh = tonumber(dataRet.refresh)
                for k,v in pairs(dataRet.rivalList) do
                    if(tonumber(v.point)>=1000)then
                        table.insert(rivalList,{["fight_force"]=tonumber(v.fight_force),["point"]=tonumber(v.point),["uid"]=tonumber(v.uid)})
                    end
                end
                printT(rivalList)
                if(table.isEmpty(rivalList))then
                    refreshRivalList()
                    return
                end
                table.sort(rivalList,function(a,b)
                    return a.point>b.point
                end)
                schedule(nil,function() fightRankChallenge(1) end,0.2)
            end
        end
        Network.no_loading_rpc(requestFunc, "compete.getCompeteInfo", "compete.getCompeteInfo", nil, true)
    end
    -- 刷新对手
    function refreshRivalList(  )
        showTip("比武刷新对手")
        local function requestFunc( cbFlag, dictData, bRet )
            -- prints("refreshRivalList---后端数据")
            -- printT( dictData)
            if(bRet == true)then
                local dataRet = dictData.ret
                printT(dataRet)
                if(dataRet==nil)then
                    showTip("比武刷新返回数据错误")
                    return
                end
                for k,v in pairs(dataRet) do
                    for i,u in pairs(atkFailUids)do
                        if(tonumber(v.uid)~=u)then
                            if(tonumber(v.point)>=1000)then
                                table.insert(rivalList,{["fight_force"]=tonumber(v.fight_force),["point"]=tonumber(v.point),["uid"]=tonumber(v.uid)})
                            end
                        end
                    end
                end
                if(table.isEmpty(rivalList))then
                    -- refreshRivalList()
                    showTip("没有满足条件的对手")
                    return
                end
                table.sort(rivalList,function(a,b)
                    return a.point>b.point
                end)
                schedule(nil,function() fightRankChallenge(1) end,0.2)
            end
        end
        Network.no_loading_rpc(requestFunc, "compete.refreshRivalList", "compete.refreshRivalList", nil, true)
    end
    -- 比武
    -- atkedUid:敌人uid
    -- type:0是比武,1是复仇
    -- callbackFunc:回调
    -- 加一个参数 itemBtn 防止发送两次请求
    function contest( atkedUid, type )
        showTip("比武攻打")
        local function requestFunc( cbFlag, dictData, bRet )
            -- prints ("contest---后端数据")
            -- printT( dictData)
            if(bRet == true)then
                local dataRet = dictData.ret
            end
        end
        -- 参数
        local args = CCArray:create()
        args:addObject(CCInteger:create(atkedUid))
        args:addObject(CCInteger:create(type))
        Network.no_loading_rpc(requestFunc, "compete.contest", "compete.contest", args, true)
    end
    -- 比武购买次数
    -- num:数量
    -- callbackFunc:回调
    function buyCompeteNum( buyNum )
        showTip("比武购买次数")
        local function requestFunc( cbFlag, dictData, bRet )
            -- prints ("buyCompeteNum---后端数据")
            -- printT( dictData)
            if(bRet == true)then
                local dataRet = dictData.ret
                -- printT(dataRet)
                UserModel.addGoldNumber(-buyNum*20)
                schedule(nil,getCompeteInfo,0.2)
            end
        end
        -- 参数
        local args = CCArray:create()
        args:addObject(CCInteger:create(tonumber(buyNum)))
        Network.no_loading_rpc(requestFunc, "compete.buyCompeteNum", "compete.buyCompeteNum", args, true)
    end
    -- public function contestMany($atkedUid, $type = 0, $num, $fresh);
    --/**
    -- * 快速比武
    -- atkedUid:敌人uid
    -- type:0是比武,1是复仇
    -- num:攻打次数
    -- fresh:攻打完是否刷新
    -- * @param pCallback 回调方法
    -- * @param pParam 参数
    -- * @return
    -- */
    local index = 0
    function contestMany( atkedUid,type,num,fresh)
        showTip("比武多次攻打")
        local requestFunc = function(cbFlag, dictData, bRet)
            -- printT( dictData)
            if dictData.err == "ok" then
                showTip("比武挑战成功")
                UserModel.addStaminaNumber(-num*2)
                if(callbackFunc~=nil)then
                    callbackFunc()
                end
            else
                --报错处理
                -- printT(dictData)
                showTip("比武挑战失败")
            end
        end
        index = index + 1
        local args = Network.argsHandlerOfTable({ atkedUid,type,num,fresh })
        Network.no_loading_rpc(requestFunc, "compete.contestMany" .. index, "compete.contestMany", args, true)
    end
    getCompeteInfo()
end

function compete_contest_set_num_UI(showDialog)
    local curTime = TimeUtil.getSvrTimeByOffset()
    if(curTime<=TimeUtil.getIntervalByTime("080000") or curTime>=TimeUtil.getIntervalByTime("230000"))then
        showTip("当前时间比武无法攻打")
        return
    end
    if(getWeekNum()==7)then
        showTip("当前时间比武无法攻打")
        return
    end
    --背包是否满
    if isBagFull(true) then
        showTip("背包满了")
        stopSweep()
        return
    end
    local num = 0
    local canBuyNum = 0
    local itemArr = {["1"]=10041, ["5"]=10042, ["10"]=10043}
    local hasNum = math.floor(UserModel.getStaminaNumber()/2)
    for k,itemId in pairs(itemArr) do
        local energyInfo = ItemUtil.getCacheItemInfoBy(itemId) -- 耐力丹
        if not table.isEmpty(energyInfo) and tonumber(energyInfo.item_num) > 0 then
            hasNum = hasNum + tonumber(energyInfo.item_num)*tonumber(k)
        end
    end
    -- if(hasNum>600)then
    --     hasNum = 600
    -- end
    local function setNum(num)
        if(num<=0)then
            showTip("比武次数必须大于0")
            return 
        end
        -- showTip(num)
        local function callback()
            compete_contest(num)
        end
        useItem_stamina(num*2,callback)
    end
    local function requestFunc(cbFlag, dictData, bRet)
        if dictData.err == "ok" then
            local info = dictData.ret
            local PseasonNum = tonumber(info.period) -- 当前是第几季
            local curDay = tonumber(info.day) -- 当前是活动第几天
            local festivalAct = ActivityConfigUtil.getDataByKey("festivalAct").data
            local periodStartTime = TimeUtil.getIntervalByTimeDesString(festivalAct[PseasonNum].start_time)
            local periodEndTime = TimeUtil.getIntervalByTimeDesString(festivalAct[PseasonNum].end_time)
            local periodDayNum = math.ceil((periodEndTime - periodStartTime)/86400)--当前季总天数
            local festivalActReward = ActivityConfigUtil.getDataByKey("festivalActReward").data
            local taskList2 = festivalAct[PseasonNum].mission_2
            local biwu = string.find(taskList2,"105006")
            if(biwu~=nil)then
                local taskInfo = info.data[tostring(PseasonNum)]["1"]
                local goalNum = tonumber(festivalActReward[105006].finish) -- 目标次数
                local finishNum = tonumber(taskInfo["105006"][1]) -- 已完成次数
                local perDayGoalNum = math.floor((goalNum-finishNum)/(periodDayNum*PseasonNum+1-curDay)) -- 目标次数
                local needNum = math.min(perDayGoalNum,math.floor(UserModel.getStaminaNumber()/2))-- 默认攻打次数为还需任务次数和耐力可打次数最大值
                local desc = "狂欢比武进度：" .. finishNum.. "/".. goalNum..",还需"..math.max(goalNum - finishNum,0).."次"
                if(showDialog~=false)then
                    creteNumSelectUI(setNum,nil,num,canBuyNum,needNum,desc,"比武次数",0)
                end
            else
                if(showDialog~=false)then
                    creteNumSelectUI(setNum,nil,num,canBuyNum,num,"比武","比武次数",0)
                end
            end
        end
    end
    function getCompeteInfo(  )
        -- showTip("获取比武信息")
        local function requestFunc1( cbFlag, dictData, bRet )
            if(bRet == true)then
                local dataRet = dictData.ret
                -- printT(dataRet)
                local buyNum = tonumber(dataRet.buy)
                local atkNum = tonumber(dataRet.num)
                require "script/ui/match/MatchData"
                local freeNum = MatchData.getAllContestNum()
                canBuyNum = MatchData.getCanBuyMaxNum()
                num = freeNum - atkNum + buyNum
                if(isFestivalActOpen())then
                    rpcCountIndex = rpcCountIndex +1
                    Network.no_loading_rpc(requestFunc, "festivalact.getInfo"..rpcCountIndex, "festivalact.getInfo", nil, true)
                else
                    if(showDialog~=false)then
                        creteNumSelectUI(setNum,nil, num,canBuyNum,num,"比武","比武次数",0)
                    end
                end
            end
        end
        Network.no_loading_rpc(requestFunc1, "compete.getCompeteInfo", "compete.getCompeteInfo", nil, true)
    end
    getCompeteInfo()
end

--跨服悬赏任务
function worldrewardtask_donateItem()
    showTip("跨服悬赏任务")
    require "db/DB_Kuafu_daily_bounty_id"
    require "db/DB_Kuafu_daily_bounty"
    require "script/ui/worldtask/WorldRewardTaskDef"
    if(TimeUtil.getSvrTimeByOffset() > getWeekIntervalByTime(6,"230000"))then
        showTip("本期活动已结束")
        return 
    end
    readDefaultValue(false)
    local kTypeDonateItem = 8 -- 捐赠物品
    local kTypeDonateHeroRepl = 11 -- 捐赠名将碎片
    local kTypeDonateArtifact = 12 -- 捐赠神器碎片
    local kTypeDonateMagicPet = 13 -- 捐赠神兽碎片
    local itemArray = {}
    local info = nil
    local taskInfo = nil
    local goalNum = 0
    local totalTaskNum = 0
    local select_task = 0
    local rewardtaskUI = nil
    local function getTaskReward(pCallback)
        local requestFunc = function( cbFlag, dictData, bRet )
            printT(dictData)
            if bRet == true then
                showTip("领奖成功")
                table.insert(info.tasks_done,select_task)
                info.task_avail = dictData.ret.task_avail
                info.procedure = dictData.ret.procedure
                select_task = 0
                rewardtaskUI(info.task_avail)
            end
        end
        Network.no_loading_rpc(requestFunc, "worldrewardtask.reward", "worldrewardtask.reward", nil, true)
    end
    local function donateTaskByItemId( pTaskId, pItemIdArr, pCallback)
        local requestFunc = function( cbFlag, dictData, bRet )
            printT(dictData)
            if bRet == true then
                getTaskReward()
            end
        end
        printT(pItemIdArr)
        local dic = CCDictionary:create()
        for i,v in pairs (pItemIdArr) do
            dic:setObject(CCInteger:create(v.item_num),v.item_id)
        end
        local args = Network.argsHandlerOfTable({pTaskId,dic})
        Network.no_loading_rpc(requestFunc, "worldrewardtask.donateTaskByItemId", "worldrewardtask.donateTaskByItemId", args, true)
    end
    local function donateTask( pTaskId, pCallback)
        local requestFunc = function( cbFlag, dictData, bRet )
            printT(dictData)
            if bRet == true then
                showTip("捐赠"..ItemUtil.getItemById(taskInfo[tostring(pTaskId)].item_id[1]).name.."*"..taskInfo[tostring(pTaskId)].goal)
                getTaskReward()
            end
        end
        local args = Network.argsHandlerOfTable({pTaskId})
        Network.no_loading_rpc(requestFunc, "worldrewardtask.donateTask", "worldrewardtask.donateTask", args, true)
    end
    local function finishTask(task_id)
        if(taskInfo[tostring(task_id)].goal <= tonumber(info.procedure[tostring(task_id)]))then
            getTaskReward()
            return
        end
        local need_num = taskInfo[tostring(task_id)].goal-taskInfo[tostring(task_id)].procedure
        if(need_num <= 0)then
            if(taskInfo[tostring(task_id)].is_donate)then
                if(taskInfo[tostring(task_id)].type == kTypeDonateItem)then
                    donateTask(task_id)
                    return
                end
                local pItemIdArr ={}
                local cur_donate_num = 0
                for k,v in pairs(taskInfo[tostring(task_id)].pItemIdArr) do
                    local item_info = BagUtil.getItemTabByTid(v.item_id)
                    if(table.count(item_info)>0)then
                        table.insert(pItemIdArr,{["item_num"]=math.min(v.item_num,taskInfo[tostring(task_id)].goal-cur_donate_num),["item_id"]=item_info[1].item_id})
                        cur_donate_num = cur_donate_num + v.item_num
                        if(cur_donate_num >= taskInfo[tostring(task_id)].goal)then
                            break
                        end
                    end
                end
                -- showTip("pItemIdArr")
                -- printT(pItemIdArr)
                donateTaskByItemId(task_id,pItemIdArr)
            else
                getTaskReward()
            end
            return
        end
        local lableGo_to = taskInfo[tostring(task_id)].type
        if(lableGo_to == WorldRewardTaskDef.kTypeFuBen)then--副本攻伐
            useItem_energy(need_num*5,function()ncopy_sweep(need_num,getTaskReward)end)
        elseif(lableGo_to == WorldRewardTaskDef.kTypeDuoBao)then--宝物抢夺
            useItem_stamina(need_num*2,function()fragseize_oneKeySeize(true,getTaskReward,need_num)end)
        elseif(lableGo_to == WorldRewardTaskDef.kTypeArena)then--竞技场
            local curTime = TimeUtil.getSvrTimeByOffset()
            if(curTime<=TimeUtil.getIntervalByTime("223000") and curTime>=TimeUtil.getIntervalByTime("220000"))then
                showTip("当前时间竞技场无法攻打")
            else
                useItem_stamina(need_num*2,function()arena_challenge_set_num(need_num,getTaskReward)end)
            end
        elseif(lableGo_to == WorldRewardTaskDef.kTypeFight)then--比武
            local curTime = TimeUtil.getSvrTimeByOffset()
            if(curTime<=TimeUtil.getIntervalByTime("080000") or curTime>=TimeUtil.getIntervalByTime("230000") or getWeekNum()==7)then
                showTip("当前时间比武无法攻打")
            else
                useItem_stamina(need_num*2,function()compete_contest(need_num,getTaskReward)end)
            end
        elseif(lableGo_to == WorldRewardTaskDef.kTypeGodWeaponQiFu)then--神器祈福
            godbless_bless(need_num,true,getTaskReward)
        elseif(lableGo_to == WorldRewardTaskDef.kTypeGodWeaponExplor)then--神器探索
            godtower_buyNum(need_num,function()godtower_search(getTaskReward)end)
        elseif(lableGo_to == WorldRewardTaskDef.kTypeBiography)then--列传寻书
            biography_roll(need_num,getTaskReward)
        elseif(lableGo_to == WorldRewardTaskDef.kTypeSevenStar)then--七星召星
            sevenslottery_lottery(need_num,true,getTaskReward)
        elseif(lableGo_to == WorldRewardTaskDef.kTypeDreamCopy)then--梦魇试炼

        elseif(lableGo_to == kTypeDonateItem)then--捐赠物品
            local item_id = taskInfo[tostring(task_id)].item_id[1]
            if(item_id == 60033)then--聚魂珠
                local function _hunt_rapidHunt_unLimit4_60033(callbackFunc)
                    if(ItemUtil.getCacheItemNumBy(60033)>=taskInfo[tostring(task_id)].goal)then
                        if(callbackFunc~=nil)then
                            schedule(nil,function()callbackFunc()end,0.2)
                        end
                    else
                        hunt_rapidHunt_unLimit4(function()_hunt_rapidHunt_unLimit4_60033(callbackFunc)end)
                    end
                end
                _hunt_rapidHunt_unLimit4_60033(function()donateTask(task_id)end)
            elseif(item_id == 60034)then--炼魂印
                local function _hunt_rapidHunt_unLimit4_60034(callbackFunc)
                    if(ItemUtil.getCacheItemNumBy(60034)<taskInfo[tostring(task_id)].goal)then
                        if(callbackFunc~=nil)then
                            schedule(nil,function()callbackFunc()end,0.2)
                        end
                    else
                        hunt_rapidHunt_unLimit4(function()_hunt_rapidHunt_unLimit4_60034(callbackFunc)end)
                    end
                end
                _hunt_rapidHunt_unLimit4_60034(function()donateTask(task_id)end)
            elseif(item_id == 60106)then--兵书精华
                require "db/DB_Nightmare_shop"
                shopBuyItem("梦魇商店",DB_Nightmare_shop,"Nightmare_shop",{["get"]="tower.getShopInfo",["buy"]="tower.buy"},30,"cost_nightmare","baseNum",60106,need_num,function()donateTask(task_id)end)
            elseif(item_id == 60107)then--战马精华
                require "db/DB_Nightmare_shop"
            shopBuyItem("梦魇商店",DB_Nightmare_shop,"Nightmare_shop",{["get"]="tower.getShopInfo",["buy"]="tower.buy"},30,"cost_nightmare","baseNum",60107,need_num,function()donateTask(task_id)end)
            elseif(item_id == 60608)then--星魂丹
                require "db/DB_Kuafu_contest_shop"
                shopBuyItem("跨服比武商店",DB_Kuafu_contest_shop,"Kuafu_contest_shop",{["get"]="worldcompete.getShopInfo",["buy"]="worldcompete.buyGoods"},25,"price","baseNum",60608,need_num,
                function(need_buy_num)
                    if(need_buy_num>0)then
                        require "db/DB_National_war_shop"
                        shopBuyItem("国战商店",DB_National_war_shop,"National_war_shop",{["get"]="worldcompete.getShopInfo",["buy"]="worldcompete.buyGoods"},25,"cost","baseNum",60608,need_buy_num,
                        function()
                            if(need_buy_num>0)then
                                showTip("商店购买数量不足")
                                -- rewardtaskUI(info.task_avail)
                                return
                            end
                            donateTask(task_id)
                        end)
                    else
                        donateTask(task_id)
                    end
                end)
            elseif(item_id == 60045)then--战魂精魄
                require "db/DB_Copyact_shop"
                shopBuyItem("活跃商店",DB_Copyact_shop,"Copyact_shop",{["get"]="countrywarshop.getShopInfo",["buy"]="countrywarshop.buy"},36,"cost","baseNum",60045,need_num,function()donateTask(task_id)end)
            else
                showTip(ItemUtil.getItemById(taskInfo[tostring(task_id)].item_id[1]).name.."无法购买")
            end
        elseif(lableGo_to == kTypeDonateHeroRepl)then--捐赠名将碎片
            showTip("名将碎片无法购买")
        elseif(lableGo_to == kTypeDonateArtifact)then--捐赠神器碎片
            if(ItemUtil.getTreasureQualityByTid(taskInfo[tostring(task_id)].item_id[1])==7)then--红色
                useSelectItem(20304,1,
                function()
                    local pItemIdArr = {}
                    local cur_donate_num = 0
                    for k,v in pairs(taskInfo[tostring(task_id)].item_id) do
                        local item_num = ItemUtil.getCacheItemNumBy(v)
                        local item_info = BagUtil.getItemTabByTid(v)
                        if(table.count(item_info)>0)then
                            table.insert(pItemIdArr,{["item_num"]=math.min(item_num,taskInfo[tostring(task_id)].goal-cur_donate_num),["item_id"]=item_info[1].item_id}) 
                            cur_donate_num = cur_donate_num + item_num
                            if(cur_donate_num >= taskInfo[tostring(task_id)].goal)then
                                break
                            end
                        end
                    end 
                    donateTaskByItemId(task_id,pItemIdArr)
                end)
            elseif(ItemUtil.getTreasureQualityByTid(taskInfo[tostring(task_id)].item_id[1])==8)then--金色
                useSelectItem(20303,1,
                function()
                    local pItemIdArr = {}
                    local cur_donate_num = 0
                    for k,v in pairs(taskInfo[tostring(task_id)].item_id) do
                        local item_num = ItemUtil.getCacheItemNumBy(v)
                        local item_info = BagUtil.getItemTabByTid(v)
                        if(table.count(item_info)>0)then
                            table.insert(pItemIdArr,{["item_num"]=math.min(item_num,taskInfo[tostring(task_id)].goal-cur_donate_num),["item_id"]=item_info[1].item_id}) 
                            cur_donate_num = cur_donate_num + item_num
                            if(cur_donate_num >= taskInfo[tostring(task_id)].goal)then
                                break
                            end
                        end
                    end 
                    donateTaskByItemId(task_id,pItemIdArr)
                end)
            else
                showTip("当前等级神器碎片不足")
            end
        elseif(lableGo_to == kTypeDonateMagicPet)then--捐赠神兽碎片
            require "db/DB_Mythical_shop"
            shopBuyItem("神兽商店",DB_Mythical_shop,"Mythical_shop",{["get"]="magicpetcopy.getShopInfo",["buy"]="magicpetcopy.buy"},36,"costNum","baseNum",9300001,need_num,
            function(need_buy_num)
                if(need_buy_num>0)then
                    shopBuyItem("神兽商店",DB_Mythical_shop,"Mythical_shop",{["get"]="magicpetcopy.getShopInfo",["buy"]="magicpetcopy.buy"},36,"costNum","baseNum",9300002,need_num,
                    function(need_buy_num)
                        if(need_buy_num>0)then
                            shopBuyItem("神兽商店",DB_Mythical_shop,"Mythical_shop",{["get"]="magicpetcopy.getShopInfo",["buy"]="magicpetcopy.buy"},36,"costNum","baseNum",9300003,need_num,
                            function(need_buy_num)
                                if(need_buy_num>0)then
                                    showTip("商店购买数量不足")
                                    -- rewardtaskUI(info.task_avail)
                                else
                                    local pItemIdArr = {}
                                    local cur_donate_num = 0
                                    for k,v in pairs(taskInfo[tostring(task_id)].item_id) do
                                        local item_num = ItemUtil.getCacheItemNumBy(v)
                                        local item_info = BagUtil.getItemTabByTid(v)
                                        if(table.count(item_info)>0)then
                                            table.insert(pItemIdArr,{["item_num"]=math.min(item_num,taskInfo[tostring(task_id)].goal-cur_donate_num),["item_id"]=item_info[1].item_id}) 
                                            cur_donate_num = cur_donate_num + item_num
                                            if(cur_donate_num >= taskInfo[tostring(task_id)].goal)then
                                                break
                                            end
                                        end
                                    end 
                                    donateTaskByItemId(task_id,pItemIdArr)
                                end
                            end)
                        else
                            local pItemIdArr = {}
                            local cur_donate_num = 0
                            for k,v in pairs(taskInfo[tostring(task_id)].item_id) do
                                local item_num = ItemUtil.getCacheItemNumBy(v)
                                local item_info = BagUtil.getItemTabByTid(v)
                                if(table.count(item_info)>0)then
                                    table.insert(pItemIdArr,{["item_num"]=math.min(item_num,taskInfo[tostring(task_id)].goal-cur_donate_num),["item_id"]=item_info[1].item_id}) 
                                    cur_donate_num = cur_donate_num + item_num
                                    if(cur_donate_num >= taskInfo[tostring(task_id)].goal)then
                                        break
                                    end
                                end
                            end 
                            donateTaskByItemId(task_id,pItemIdArr)
                        end
                    end)
                else
                    local pItemIdArr = {}
                    local cur_donate_num = 0
                    for k,v in pairs(taskInfo[tostring(task_id)].item_id) do
                        local item_num = ItemUtil.getCacheItemNumBy(v)
                        local item_info = BagUtil.getItemTabByTid(v)
                        if(table.count(item_info)>0)then
                            table.insert(pItemIdArr,{["item_num"]=math.min(item_num,taskInfo[tostring(task_id)].goal-cur_donate_num),["item_id"]=item_info[1].item_id}) 
                            cur_donate_num = cur_donate_num + item_num
                            if(cur_donate_num >= taskInfo[tostring(task_id)].goal)then
                                break
                            end
                        end
                    end 
                    donateTaskByItemId(task_id,pItemIdArr)
                end
            end)
        else 
            showTip("暂不支持该任务类别")
        end
    end
    local function choiceTask( pTaskId, pCallback)
        if(totalTaskNum<=table.count(info.tasks_done))then
            showTip("任务次数用完，请购买")
            return
        end
        local requestFunc = function( cbFlag, dictData, bRet )
            printT(dictData)
            if bRet == true then
                select_task = pTaskId
                rewardtaskUI(info.task_avail)
                finishTask(select_task)
            end
        end
        local args = Network.argsHandlerOfTable({pTaskId})
        Network.no_loading_rpc(requestFunc, "worldrewardtask.choice", "worldrewardtask.choice", args, true)
    end
    local function refreshTask(pCallback)
        local requestFunc = function( cbFlag, dictData, bRet )
            if(totalTaskNum<=table.count(info.tasks_done))then
                showTip("任务次数用完")
                return
            end
            -- printT(dictData)
            if bRet == true then
                select_task = 0
                local refresh_num = tonumber(info.refresh_num)
                local free_refresh_num = tonumber(DB_Kuafu_daily_bounty.getDataById(1).free_refresh)
                local last_refresh_num = free_refresh_num - refresh_num -- 剩余免费刷新次数
                if(last_refresh_num<=0)then
                    UserModel.addGoldNumber(-tonumber(DB_Kuafu_daily_bounty.getDataById(1).free_refresh_gold))
                end
                info.procedure = dictData.ret.procedure
                info.task_avail = dictData.ret.task_avail
                info.refresh_num = tonumber(info.refresh_num) + 1
                rewardtaskUI(info.task_avail)
            end
        end
        Network.no_loading_rpc(requestFunc, "worldrewardtask.refresh", "worldrewardtask.refresh", nil, true)
    end
    local function getBuyTaskCost(pBuyNum)
        --剩余可购买次数
        local buyedNum = tonumber(info.buy_task_num)
        local reCostNum = 0
        local costArr = string.split(DB_Kuafu_daily_bounty.getDataById(1).extra_times_gold,",")
        for i=1,pBuyNum do
            local costIndex = i+buyedNum
            local costArr = string.split(costArr[costIndex],"|")
            reCostNum = reCostNum+tonumber(costArr[2])
        end
        return reCostNum
    end
    local function buyTaskNum( pNum, pCallback)
        local requestFunc = function( cbFlag, dictData, bRet )
            printT(dictData)
            if bRet == true then
                UserModel.addGoldNumber(-getBuyTaskCost(pNum))
                info.buy_task_num = tonumber(info.buy_task_num) + pNum
                totalTaskNum = totalTaskNum + pNum
                rewardtaskUI(info.task_avail)
            end
        end
        local args = Network.argsHandlerOfTable({pNum})
        Network.no_loading_rpc(requestFunc, "worldrewardtask.buyTaskNum", "worldrewardtask.buyTaskNum", args, true)
    end
    local function buyTaskNum_UI()
        local function setNum(num)
            if(num<=0)then
                showTip("购买次数必须大于0")
                return 
            end
            buyTaskNum(num)
        end
        local can_buy_num = (#string.split(DB_Kuafu_daily_bounty.getDataById(1).extra_times_gold,",") or 5) - tonumber(info.buy_task_num)
        if(can_buy_num<=0)then
            showTip("购买次数已用完")
            return
        end
        local default_num = 1
        creteNumSelectUI(setNum,nil,0,can_buy_num,default_num,"跨服悬赏任务购买次数,花费金币:"..getBuyTaskCost(default_num),"道具",0,1,function(label,pnum) label:setString("跨服悬赏任务购买次数,花费金币:"..getBuyTaskCost(pnum)) end)
    end
    rewardtaskUI = function(task_list)
        require "db/DB_Daily_bounty_id"
        taskInfo={}
        for k,v in pairs(task_list) do
            local db = DB_Kuafu_daily_bounty_id.getDataById(tonumber(v))
            local temp = {}
            temp.desc = db.task_des
            temp.item_id={}
            temp.pItemIdArr={}
            local goal = db.goal
            if(string.find(goal,"|")~=nil)then
                local _goal = string.split(goal,"|")
                temp.goal=tonumber(_goal[#_goal])
                if( tonumber(db.type)==8)then
                    temp.item_id = {tonumber(_goal[2])}
                else
                    local tmp={}
                    for i=1,#_goal-1 do
                        table.insert(tmp,tonumber(_goal[i]))
                    end
                    temp.item_id=tmp
                end
            else
                temp.goal = tonumber(db.goal)
            end

            local item_num = 0
            for i1=1,#temp.item_id do
                table.insert(temp.pItemIdArr,{["item_num"]=ItemUtil.getCacheItemNumBy(temp.item_id[i1]),["item_id"]=temp.item_id[i1]})
                item_num = item_num + ItemUtil.getCacheItemNumBy(temp.item_id[i1])
            end 
            table.sort(temp.pItemIdArr,function(a,b) return a.item_num<b.item_num end)
            temp.item_num = item_num
            temp.procedure = tonumber(info.procedure[tostring(v)])
            temp.can_reward = 0
            if(temp.procedure>=temp.goal and tonumber(v)==select_task)then
                temp.can_reward = 1
            end
            temp.quality = db.quality
            if( tonumber(db.type)==8)then
                temp.item_id = {tonumber(string.split(goal,"|")[2])}
            end
            temp.is_finish = 0
            for k1,v1 in pairs(info.tasks_done)do
                if(tonumber(v)==tonumber(v1))then
                    temp.is_finish = 1
                    break
                end
            end
            temp.type = tonumber(db.type)
            temp.is_donate = false
            temp.choiceTask_button_red_color = false
            local lableGo_to = tonumber(db.type)
            if(lableGo_to == WorldRewardTaskDef.kTypeFuBen)then--副本攻伐
            elseif(lableGo_to == WorldRewardTaskDef.kTypeDuoBao)then--宝物抢夺
            elseif(lableGo_to == WorldRewardTaskDef.kTypeArena)then--竞技场
            elseif(lableGo_to == WorldRewardTaskDef.kTypeFight)then--比武
            elseif(lableGo_to == WorldRewardTaskDef.kTypeGodWeaponQiFu)then--神器祈福
            elseif(lableGo_to == WorldRewardTaskDef.kTypeGodWeaponExplor)then--神器探索
            elseif(lableGo_to == WorldRewardTaskDef.kTypeBiography)then--列传寻书
            elseif(lableGo_to == WorldRewardTaskDef.kTypeSevenStar)then--七星召星
            elseif(lableGo_to == WorldRewardTaskDef.kTypeDreamCopy)then--梦魇试炼
            else -- 捐赠物品
                temp.procedure = item_num
                temp.is_donate = true
                if(lableGo_to == kTypeDonateItem)then--捐赠物品
                    local item_id = temp.item_id[1]
                    if(item_id == 60033)then--聚魂珠
                    elseif(item_id == 60034)then--炼魂印
                    elseif(item_id == 60106)then--兵书精华
                    elseif(item_id == 60107)then--战马精华
                    elseif(item_id == 60608)then--星魂丹
                    elseif(item_id == 60045)then--战魂精魄
                    else--其他物品暂不支持购买
                        if(temp.procedure<temp.goal)then
                            temp.choiceTask_button_red_color = true
                        end
                    end
                elseif(lableGo_to == kTypeDonateArtifact)then--神器碎片
                    if(ItemUtil.getTreasureQualityByTid(temp.item_id[1])==7)then--红色
                    elseif(ItemUtil.getTreasureQualityByTid(temp.item_id[1])==8)then--金色
                    else--其他品质神器碎片暂不支持开箱获取
                        if(temp.procedure<temp.goal)then
                            temp.choiceTask_button_red_color = true
                        end
                    end
                elseif(lableGo_to == kTypeDonateHeroRepl)then--名将碎片
                    if(temp.procedure<temp.goal)then
                        temp.choiceTask_button_red_color = true
                    end
                elseif(lableGo_to == kTypeDonateMagicPet)then--名将碎片
                    if(temp.procedure<temp.goal)then
                        temp.choiceTask_button_red_color = true
                    end
                end
            end
            taskInfo[tostring(v)] = temp
        end

        --刷新模块文本
        local refresh_num = tonumber(info.refresh_num)
        local free_refresh_num = tonumber(DB_Kuafu_daily_bounty.getDataById(1).free_refresh)
        local last_refresh_num = free_refresh_num - refresh_num -- 剩余刷新次数
        local rewardtask_refresh_desc = "5/5"
        local rewardtask_refresh_redColorTip = false
        if(last_refresh_num>0)then
            rewardtask_refresh_desc = "免费刷新"..last_refresh_num.."/"..free_refresh_num
        else
            local goldNum = tonumber(DB_Kuafu_daily_bounty.getDataById(1).free_refresh_gold)
            rewardtask_refresh_desc = "消耗金币:"..goldNum
            rewardtask_refresh_redColorTip = true--ccc3(0xff,0x0,0x0)
        end
        --出现一键完成的最小任务品质
        local min_currency = default_value["worldrewardtask_quality"] or 6


        require "script/ui/hero/HeroPublicLua"
        local finish_num = table.count(info.tasks_done)
        local can_buy_num = (#string.split(DB_Kuafu_daily_bounty.getDataById(1).extra_times_gold,",") or 5) - tonumber(info.buy_task_num)
        local buy_redColorTip = false
        if(can_buy_num<=0)then
            buy_redColorTip = true
        end
        local taskInfoText = {{["text"]="已完成任务数量:"..finish_num.."/"..totalTaskNum,["color"]=nil}}
        local buttonFunc = {{["text"]="刷新",["func"]=refreshTask,["desc"]=rewardtask_refresh_desc,["redColor"]=rewardtask_refresh_redColorTip},
                            {["text"]="购买次数",["func"]=buyTaskNum_UI,["desc"]="剩余购买次数:"..can_buy_num,["redColor"]=buy_redColorTip,["isDisableBtn"]=(can_buy_num<=0)}}

        local n = 0
        for k,v in pairs(taskInfo) do 
            n = n + 1        
            if(v.is_finish==1)then
                table.insert(taskInfoText,{["text"]="任务"..n.."\n"..v.desc,["color"]=HeroPublicLua.getCCColorByStarLevel(v.quality),
                ["btn"]={["text"]="已完成",["isDisableBtn"]=true}})
            elseif(v.quality<min_currency)then
                table.insert(taskInfoText,{["text"]="任务"..n.."\n"..v.desc,["color"]=HeroPublicLua.getCCColorByStarLevel(v.quality),
                ["align"]="left"})
            elseif(v.can_reward==1)then
                table.insert(taskInfoText,{["text"]="任务"..n.."\n"..v.desc,["color"]=HeroPublicLua.getCCColorByStarLevel(v.quality),
                ["btn"]={["text"]="领取"..n,["func"]=function()getTaskReward(tonumber(k))end,["desc"]=v.procedure.."/"..v.goal,["redColor"]=v.choiceTask_button_red_color}})
            elseif(select_task==0)then
                table.insert(taskInfoText,{["text"]="任务"..n.."\n"..v.desc,["color"]=HeroPublicLua.getCCColorByStarLevel(v.quality),
                ["btn"]={["text"]="接受"..n,["func"]=function()choiceTask(tonumber(k))end,
                ["desc"]=v.procedure.."/"..v.goal,["redColor"]=v.choiceTask_button_red_color}})
            elseif(select_task==tonumber(k))then
                table.insert(taskInfoText,{["text"]="任务"..n.."\n"..v.desc,["color"]=HeroPublicLua.getCCColorByStarLevel(v.quality),
                ["btn"]={["text"]="完成"..n,["func"]=function()finishTask(tonumber(k))end,
                ["desc"]=v.procedure.."/"..v.goal,["redColor"]=v.choiceTask_button_red_color}})
            else
                table.insert(taskInfoText,{["text"]="任务"..n.."\n"..v.desc,["color"]=HeroPublicLua.getCCColorByStarLevel(v.quality),
                ["btn"]={["text"]="接受"..n,["func"]=function()choiceTask(tonumber(k))end,["desc"]=v.procedure.."/"..v.goal,["redColor"]=v.choiceTask_button_red_color}})
            end
        end
        createTaskUI("跨服悬赏任务",taskInfoText,buttonFunc)
    end
    local function requestFunc( cbFlag, dictData, bRet )
        if dictData.err == "ok" then
            info = dictData.ret
            printT(info)
            -- if(1)then return end
            local finish_num = table.count(info.tasks_done)
            local buy_task_num = tonumber(info.buy_task_num)
            local free_task_num = tonumber(DB_Kuafu_daily_bounty.getDataById(1).day_task_freetimes) or 5
            totalTaskNum = free_task_num+buy_task_num
            select_task = tonumber(info.task_id)
            local can_buy_num = #string.split(DB_Kuafu_daily_bounty.getDataById(1).extra_times_gold,",") or 5
            if((free_task_num + can_buy_num) <= finish_num)then
                showTip("跨服悬赏任务剩余次数不足")
                return
            end
            rewardtaskUI(info.task_avail)
            updateUserInfo()
        end
    end
    Network.no_loading_rpc(requestFunc, "worldrewardtask.getWorldRewardTask", "worldrewardtask.getWorldRewardTask", nil, true)
end

--补给卡
function directsubsidy_gainTaskReward()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("补给卡")
    local kActID = 2 --补给卡对应DB_Act_direct_ids表id
    local day_num = 0 -- 活动持续天数
    local cur_day = 0 -- 当前为第几天
    local info = {}
    local task_reward = {}
    local task_ids ={}
    local gainReward = nil
    local function getServerNameByActID(pActID)
        local retData = nil
        require "db/DB_Act_direct_ids"
        local dbData = DB_Act_direct_ids.getDataById(pActID)
        --活动类的判断
        if dbData and dbData.is_active and dbData.sever_name then
            --后端活动表名，多个表用|分割, 默认活动第一个表开了就代表活动开了
            local serverNames = string.split(dbData.sever_name, "|")
            retData = serverNames[1]
        end
        return retData
    end
    local function getStartTime()
        local serverName = getServerNameByActID(kActID)
        local time = ActivityConfigUtil.getDataByKey(serverName).start_time
        return time
    end
    --结束时间
    local function getEndTime()
        local serverName = getServerNameByActID(kActID)
        local time = ActivityConfigUtil.getDataByKey(serverName).end_time
        return time
    end

    local function gainTaskReward(pCallback, id, isGold)
        local requestFunc = function(cbFlag, dictData, bRet)
            printT(dictData)
            if dictData.err == "ok" then
                for k,v in pairs(task_ids) do
                    if(v.id == id)then
                        showTip("第"..k.."天补给卡任务奖励领取成功")
                        v.get = 1
                    end
                end
                if pCallback then
                    schedule(nil,pCallback,0.2)
                end
            end
        end
        local args = Network.argsHandlerOfTable({ id, isGold })--id 对应任务ID, isGold 是否是补签 1是  0否
        Network.no_loading_rpc(requestFunc, "directsubsidy.gainTaskReward", "directsubsidy.gainTaskReward", args, true)
    end
    gainReward = function()
        for i=1,cur_day do
            local isGold = 1
            if(i==cur_day)then
                isGold = 0
            end
            if(task_ids[i].get==0)then
                gainTaskReward(gainReward,task_ids[i].id,isGold)
                return
            end
        end
        showTip("补给卡任务奖励已全部领取")
        finish_table["directsubsidy_gainTaskReward"] = 1
    end
    local function getInfo()
        local requestFunc = function(cbFlag, dictData, bRet)
            printT(dictData)
            if dictData.err == "ok" then
                info = dictData.ret
                cur_day = tonumber(info.day)
                day_num = math.ceil((getEndTime()-getStartTime())/86400)
                local serverName = getServerNameByActID(kActID)
                local data = ActivityConfigUtil.getDataByKey(serverName).data
                local task_id = {}
                if(data[1]~=nil and data[1].task_id~=nil)then
                    task_id = string.split(data[1].task_id,"|")
                end
                for k,v in pairs(task_id) do
                    table.insert(task_ids,{["id"]=tonumber(v),["get"]=0})
                end
                table.sort(task_ids,function(a,b)
                    return a.id<b.id
                end)
                for k,v in pairs(info.task_reward)do
                    for a,b in pairs(task_ids) do
                        if(tonumber(v)==b.id)then
                            b.get = 1
                        end
                    end
                end
                gainReward()
            end
        end
        Network.no_loading_rpc(requestFunc, "directsubsidy.getInfo", "directsubsidy.getInfo", nil, true)
    end
    getInfo()
end

--助力卡
function directassist_gainTaskReward()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("助力卡")
    local kActID = 1 --助力卡对应DB_Act_direct_ids表id
    local day_num = 0 -- 活动持续天数
    local cur_day = 0 -- 当前为第几天
    local info = {}
    local task_reward = {}
    local task_ids ={}
    local gainReward = nil
    local function getServerNameByActID(pActID)
        local retData = nil
        require "db/DB_Act_direct_ids"
        local dbData = DB_Act_direct_ids.getDataById(pActID)
        --活动类的判断
        if dbData and dbData.is_active and dbData.sever_name then
            --后端活动表名，多个表用|分割, 默认活动第一个表开了就代表活动开了
            local serverNames = string.split(dbData.sever_name, "|")
            retData = serverNames[1]
        end
        return retData
    end
    local function getStartTime()
        local serverName = getServerNameByActID(kActID)
        local time = ActivityConfigUtil.getDataByKey(serverName).start_time
        return time
    end
    --结束时间
    local function getEndTime()
        local serverName = getServerNameByActID(kActID)
        local time = ActivityConfigUtil.getDataByKey(serverName).end_time
        return time
    end

    local function gainTaskReward(pCallback, id, isGold)
        local requestFunc = function(cbFlag, dictData, bRet)
            printT(dictData)
            if dictData.err == "ok" then
                for k,v in pairs(task_ids) do
                    if(v.id == id)then
                        showTip("第"..k.."天助力卡任务奖励领取成功")
                        v.get = 1
                    end
                end
                if pCallback then
                    schedule(nil,pCallback,0.2)
                end
            end
        end
        local args = Network.argsHandlerOfTable({ id, isGold })--id 对应任务ID, isGold 是否是补签 1是  0否
        Network.no_loading_rpc(requestFunc, "directassist.gainTaskReward", "directassist.gainTaskReward", args, true)
    end
    gainReward = function()
        for i=1,cur_day do
            local isGold = 1
            if(i==cur_day)then
                isGold = 0
            end
            if(task_ids[i].get==0)then
                gainTaskReward(gainReward,task_ids[i].id,isGold)
                return
            end
        end
        showTip("助力卡任务奖励已全部领取")
        finish_table["directassist_gainTaskReward"] = 1
    end
    local function getInfo()
        local requestFunc = function(cbFlag, dictData, bRet)
            printT(dictData)
            if dictData.err == "ok" then
                info = dictData.ret
                cur_day = tonumber(info.day)
                day_num = math.ceil((getEndTime()-getStartTime())/86400)
                local serverName = getServerNameByActID(kActID)
                local data = ActivityConfigUtil.getDataByKey(serverName).data
                local task_id = {}
                if(data[1]~=nil and data[1].task_id~=nil)then
                    task_id = string.split(data[1].task_id,"|")
                end
                for k,v in pairs(task_id) do
                    table.insert(task_ids,{["id"]=tonumber(v),["get"]=0})
                end
                table.sort(task_ids,function(a,b)
                    return a.id<b.id
                end)
                for k,v in pairs(info.task_reward)do
                    for a,b in pairs(task_ids) do
                        if(tonumber(v)==b.id)then
                            b.get = 1
                        end
                    end
                end
                gainReward()
            end
        end
        Network.no_loading_rpc(requestFunc, "directassist.getInfo", "directassist.getInfo", nil, true)
    end
    getInfo()
end

-- 节日回馈(气球)签到
function anniveleven_recvSignReward()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("节日回馈(气球)签到")
    local cur_day = 0
    local info = {}
    local sign_info = {}
    local need_sign_id ={}
    local function isHaveSign(pId)
        local retData = false
        local signData = sign_info.va_sign or {}
        for i,v in pairs(signData) do
            if tonumber(v) == tonumber(pId) then
                retData = true
                break
            end
        end
        return retData
    end
    local function getSignListData()
        local dbData = ActivityConfigUtil.getDataByKey("annivElevenSign").data
        local retData = {}
        for k,v in pairs(dbData) do
            if tonumber(v.type) == 1 then
                table.insert(retData, v)
            end 
        end
        table.sort( retData, function ( data1, data2 )
            return tonumber(data1.id) < tonumber(data2.id)
        end )
        return retData
    end
    -- printT(getSignListData())
    local function recvSignReward(pParam)
        local requestFunc = function(cbFlag, dictData, bRet)
            if dictData.err == "ok" then
                showTip("节日回馈(气球)签到成功")
                finish_table["anniveleven_recvSignReward"] = 1
            end
        end
        local args = Network.argsHandlerOfTable({ pParam })
        Network.no_loading_rpc(requestFunc, "anniveleven.recvSignReward", "anniveleven.recvSignReward", args, true)
    end
    local function getInfo()
        local requestFunc = function(cbFlag, dictData, bRet)
            if dictData.err == "ok" then
                -- printT(dictData)
                -- info = dictData.ret
                -- printT(info)
                sign_info = dictData.ret.sign
                cur_day = tonumber(sign_info.today)
                local listData = getSignListData()
                for i,v in ipairs(listData) do
                    if tonumber(i) <= cur_day then
                        local isSign = isHaveSign(v.id)
                        if not isSign then
                            table.insert(need_sign_id, tonumber(v.id))
                        end
                    end
                end
                recvSignReward(need_sign_id)
            end
        end
        Network.no_loading_rpc(requestFunc, "anniveleven.getInfo", "anniveleven.getInfo", nil, true)
    end
    getInfo()
end
--跨服军团贡献和祈福
function worldguild_contribute()
    if(not DataCache.getSwitchNodeState(ksKFGuild,false))then
        showTip("跨服军团，等级未达到")
        return
    end
    local contri_num = 0
    local reward_num = 0
    local function reward(pType)
        local requestFunc = function( cbFlag, dictData, bRet )
            if bRet == true then
                reward_num = reward_num + 1
                showTip("第"..reward_num.."次祈福成功")
                local set_num = default_value["worldguild_reward"] or 3
                local num = set_num - reward_num
                if(num>0)then
                    schedule(nil,function()reward(1)end,0.2)--金币祈福
                else
                    showTip("跨服军团今日已经祈福")
                    finish_table["worldguild_reward"] = 1
                end 
            end
        end
        local args = Network.argsHandlerOfTable({pType})
        Network.no_loading_rpc(requestFunc, "worldguild.reward", "worldguild.reward", args, true)
    end
    local function contribute(pType)
        local requestFunc = function( cbFlag, dictData, bRet )
            if bRet == true then
                showTip("捐赠成功")
                finish_table["worldguild_contribute"] = 1
                local set_num = default_value["worldguild_reward"] or 3
                local num = set_num - reward_num
                if(num>0)then
                    if(reward_num==0)then
                        schedule(nil,function()reward(0)end,0.2)--免费祈福
                    else
                        schedule(nil,function()reward(1)end,0.2)--金币祈福
                    end
                else
                    showTip("跨服军团今日已经祈福")
                    finish_table["worldguild_reward"] = 1
                end 
            end
        end
        local args = Network.argsHandlerOfTable({pType})
        Network.no_loading_rpc(requestFunc, "worldguild.contribute", "worldguild.contribute", args, true)
    end
    local function getMemberInfo()
        local requestFunc = function( cbFlag, dictData, bRet )
            printT(dictData)
            if bRet == true then
                local curTime = TimeUtil.getSvrTimeByOffset()
                if dictData["ret"]then
                    if dictData.ret.quit_time and (curTime < tonumber(dictData.ret.quit_time) + 86400) then
                        showTip("跨服军团退团时间："..TimeUtil.getTimeFormatYMDHMS(dictData.ret.quit_time))
                        return
                    end
                end
                if dictData.ret.guild_id==nil or tonumber(dictData.ret.guild_id) == 0 then
                    showTip("未加入跨服军团")
                    return
                else
                    contri_num = tonumber(dictData.ret.contri_num)
                    reward_num = tonumber(dictData.ret.reward_num)
                    if(tonumber(dictData.ret.contri_num)>0)then
                        showTip("跨服军团今日已经贡献")
                        local set_num = default_value["worldguild_reward"] or 3
                        local num = set_num - reward_num
                        if(num>0)then
                            if(reward_num==0)then
                                schedule(nil,function()reward(0)end,0.2)--免费祈福
                            else
                                schedule(nil,function()reward(1)end,0.2)--金币祈福
                            end
                        else
                            showTip("跨服军团今日已经祈福")
                            finish_table["worldguild_reward"] = 1
                        end 
                    else
                        local _type = tonumber(default_value["worldguild_contribute"]) or 5
                        _type = math.max(1,math.min(5,_type))--限定范围1~5
                        schedule(nil,function()contribute(_type)end,0.2)
                    end
                end
            end
        end
        -- local args = Network.argsHandlerOfTable({pArg1})
        Network.no_loading_rpc(requestFunc, "worldguild.getMemberInfo", "worldguild.getMemberInfo", args, true)
    end
    getMemberInfo()
end


-- 节日回馈(气球)任务
function anniveleven_recvTaskReward()
    --背包是否满
	if isBagFull(true) then
		showTip("背包满了")
        stopSweep()
		return
	end
    showTip("节日回馈(气球)任务")
    local info = {}
    local need_reward_id ={}
    local function isTaskHaveReceive(pId)
        local retData = false
        local taskData = info.carnival.had_carinvalReward or {}
        for i,v in pairs(taskData) do
            if tonumber(v) == tonumber(pId) then
                retData = true
                break
            end
        end
        return retData
    end 
    local function getTaskOverNum(pType)
        local retData = 0
        local taskData = info.carnival.task or {}
        for k,v in pairs(taskData) do
            if tonumber(k) == tonumber(pType) then
                retData = tonumber(v)
                break
            end
        end
        return retData
    end
    local function isTaskCanReceive(pId)
        local isHave = isTaskHaveReceive(pId)
        if isHave then
            return false
        end
        local dbDataT = ActivityConfigUtil.getDataByKey("annivElevenCarnival").data
        local dbData = dbDataT[tonumber(pId)]
        local overNum = getTaskOverNum(dbData.day_type)
        local needOverNum = tonumber(dbData.task1)
        return overNum >= needOverNum
    end
    local function getTaskListData(pDay)
        local dbData = ActivityConfigUtil.getDataByKey("annivElevenCarnival").data
        local retData = {}
        for k,v in pairs(dbData) do
            if tonumber(v.day) == tonumber(pDay) then
                local isCan = isTaskCanReceive(v.id)
                if isCan then
                    table.insert(retData, v)
                end
            end 
        end
        table.sort( retData, function ( data1, data2 )
            return tonumber(data1.id) < tonumber(data2.id)
        end )
        return retData
    end
    local function recvTaskReward()
        -- printT(need_reward_id)
        if(table.count(need_reward_id)==0)then
            finish_table["anniveleven_recvTaskReward"] = 1
            showTip("节日回馈(气球)任务领奖完毕")
            return
        end
        local requestFunc = function(cbFlag, dictData, bRet)
            printT(dictData)
            if dictData.err == "ok" then
                showTip("节日回馈(气球)任务领奖成功,剩余"..table.count(need_reward_id).."个")
                table.remove(need_reward_id)
                schedule(nil,recvTaskReward,0.2)
                if(table.count(need_reward_id)==0)then
                    finish_table["anniveleven_recvTaskReward"] = 1
                    showTip("节日回馈(气球)任务领奖完毕")
                    return
                end
            end
        end
        local args = Network.argsHandlerOfTable( {need_reward_id[#need_reward_id]} )
        Network.no_loading_rpc(requestFunc, "anniveleven.recvTaskReward", "anniveleven.recvTaskReward", args, true)
    end
    local function getInfo()
        local requestFunc = function(cbFlag, dictData, bRet)
            if dictData.err == "ok" then
                -- printT(dictData)
                info = dictData.ret
                -- printT(info)
                -- local dbDataT = ActivityConfigUtil.getDataByKey("annivElevenCarnival").data
                -- printT(dbDataT)
                -- printT(info.carnival.task)
                for i=1,table.count(info.carnival.task) do
                    for k,v in pairs(getTaskListData(i))do
                        table.insert(need_reward_id,tonumber(v.id))
                    end
                end
                -- printT(need_reward_id)
                recvTaskReward()
            end
        end
        Network.no_loading_rpc(requestFunc, "anniveleven.getInfo", "anniveleven.getInfo", nil, true)
    end
    getInfo()
end

--直购战令
function directwarorder_gainReward()
    showTip("直购战令")
    if isBagFull(true) then
        showTip("背包满了")
        return
  	end
    require "script/ui/rechargeActive/directWarOrder/DirectWarOrderData"
    local getInfo = function()end
    local all_recharge = string.split(ActivityConfigUtil.getDataByKey("directWarOrder").data[1].all_recharge,",")
    local TAB_NUM=table.count(all_recharge) -- 充值档位个数
    local _info = {}
    local function getListData(pIndex)
        local retData = {}
        local retData1 = {} --已领取的
        local dbData = ActivityConfigUtil.getDataByKey("directWarOrder").data
        for k,v in ipairs(dbData) do
            table.insert(retData,v)
        end
        table.sort( retData, function ( data1, data2 )
            return tonumber(data1.id) < tonumber(data2.id)
        end )
        table.sort( retData1, function ( data1, data2 )
            return tonumber(data1.id) < tonumber(data2.id)
        end )
        for i,v in ipairs(retData1) do
            table.insert(retData,v)
        end
        return retData
    end
    local function isHaveRewardBy(pId, pType, pIndex)
        local retData = false
        local rewardInfo = _info.reward and _info.reward[tostring(pIndex)] or {}
        for k, v in pairs(rewardInfo[tostring(pType)] or {}) do
            if tonumber(v) == tonumber(pId) then
                retData = true
                break
            end
        end
        return retData
    end
    local function isBuyByIndex(pIndex)
        local retData = false
        for k,v in pairs(_info.arr_gear or {}) do
            if tonumber(v) == tonumber(pIndex) then
                retData = true
                break
            end
        end	
        return retData
    end
    local function isCanRewardBy(pId, pType, pIndex)
        local dbData1 = ActivityConfigUtil.getDataByKey("directWarOrder").data
        local dbData = dbData1[tonumber(pId)]
        if not dbData then
            return false
        end
        --需求不足
        local costNum = tonumber(_info.cost_gold) or 0
        local needCost = tonumber(dbData.gold_cost) or 0
        if needCost > costNum then
            return false
        end
        --已领取
        local isHave = isHaveRewardBy(pId, pType, pIndex)
        if isHave then
            return false
        end
        --如果是付费 没买这个档位
        local isBuy = isBuyByIndex(pIndex)
        if tonumber(pType) == 2 and not isBuy then
            return false
        end
        return true
    end
    local function getCanRewardData(pIndex)
        local retData = {}
        retData["1"] = {} --免费
        retData["2"] = {} --付费
        local listData = getListData(pIndex)
        for k,v in pairs(listData) do
            local isCan = isCanRewardBy(v.id,1,pIndex)
            if isCan then
                table.insert(retData["1"],v.id)
            end
            local isCan2 = isCanRewardBy(v.id,2,pIndex)
            if isCan2 then
                table.insert(retData["2"],v.id)
            end
        end
        return retData
    end
    local function gainReward(pParam1, pParam2, pParam3)
        local requestFunc = function(cbFlag, dictData, bRet)
            if dictData.err == "ok" then
                printT(dictData)
                if(pParam1<=TAB_NUM)then
                    showTip("直购战令第".. pParam1 .."档免费奖励领取成功")
                else
                    finish_table["directwarorder_gainReward"] = 1
                    showTip("直购战令免费奖励领取完毕")
                end
            end
        end
        local args = Network.argsHandlerOfTable({ pParam1, pParam2, pParam3 })
        Network.no_loading_rpc(requestFunc, "directwarorder.gainReward", "directwarorder.gainReward", args, true)
    end
    local function getInfo(pType)
        local requestFunc = function(cbFlag, dictData, bRet)
            if dictData.err == "ok" then
                printT(dictData)
                _info = dictData.ret
                for pIndex=1,TAB_NUM do
                    local canArr = getCanRewardData(pIndex)
                    local canArgs = canArr[tostring(pType)]
                    if not table.isEmpty(canArgs) then
                        schedule(nil,function()gainReward(pIndex,canArgs,{})end,pIndex*0.2)
                    else
                        showTip("直购战令第".. pIndex .."档免费奖励已领取")
                    end
                end
            end
        end
        Network.no_loading_rpc(requestFunc, "directwarorder.getInfo", "directwarorder.getInfo", nil, true)
    end
    getInfo(1)
end


-- 读取当前账号当日已完成任务列表
function readSweepStatus()
    local server_id = UserModel.getServerId()
    local pid = UserModel.getPid()
    local path = CCFileUtils:sharedFileUtils():getWritablePath().. "Resources/script/ui/main/log/" .. server_id .. " " .. pid .. ".log"
    if (CCFileUtils:sharedFileUtils():isFileExist(path) == false) then
        showTip("已完成任务列表文件不存在")
        finish_table = {}
        return
    end
    io.input(path)
    local Buffer = io.read("*all")
    local task = string.split(Buffer, "\n")
    for k, v in pairs(task) do
        if (string.len(v) ~= 0) then
            local name_value = string.split(v, ",")
            finish_table[name_value[1]] = tonumber(name_value[2])
        end
    end
    if (finish_table["time"] ~= nil and TimeUtil.isSameDay(TimeUtil.getCurDayZeroTime(), finish_table["time"])) then
        return
    end
    showTip("已完成任务列表文件时间不是今日")
    finish_table = {}
end
-- 写入当前账号当日已完成任务列表
function writeSweepStatus()
    -- finish_table["time"] = TimeUtil.getCurDayZeroTime()
    local str = ""
    for k, v in pairs(finish_table) do
        str = str .. k .. "," .. v .. "\n"
    end
    local server_id = UserModel.getServerId()
    local pid = UserModel.getPid()
    if (CCFileUtils:sharedFileUtils():isFileExist(CCFileUtils:sharedFileUtils():getWritablePath().. "Resources/script/ui/main/log/") ~= true) then
        local ret = os.execute("mkdir "..CCFileUtils:sharedFileUtils():getWritablePath().. "Resources/script/ui/main/log/")
        if ret ~= 0 then
            showTip("文件夹创建失败")
            return false
        else
            showTip("文件夹创建成功")
        end
    end
    local path = CCFileUtils:sharedFileUtils():getWritablePath().. "Resources/script/ui/main/log/" .. server_id .. " " .. pid .. ".log"
    local file = io.open(path, "w+")
    file:write(str)
    file:close()
end
function showId()
    local server_id = UserModel.getServerId()
    local pid = UserModel.getPid()
    showTip("server_id:"..server_id..", pid:"..pid)
end

-- 扫荡结束提示
function sweepEnd()
    if(sweeping==1)then
        sweeping=0
        writeSweepStatus()
        require "script/ui/tip/AlertTip"
        AlertTip.showAlert("一键扫荡结束")
    else
        showTip("一键扫荡结束")
        writeSweepStatus()
        sweeping = 0
    end
end
function stopSweep()
    if(sweeping==1)then
    _bgLayer:stopAction(mainSeqAct)
    writeSweepStatus()
    sweeping = 0
    end
end
function sweep()
    if(sweeping==1)then
        showTip("正在扫荡中")
        return 
    end
    sweeping = 1
    init()
    readDefaultValue()
    readSweepStatus()
    finish_table["time"] = TimeUtil.getSvrTimeByOffset()
    _bgLayer = CCDirector:sharedDirector():getRunningScene()
    local actionArray = CCArray:create()
    local dely = CCDelayTime:create(1.5 * timeScale)
    -- 吃烧鸡
    if(isSupplyTime())then
        actionArray:addObject(CCCallFunc:create(supply_getSupplyInfo))
        actionArray:addObject(dely)
    end
    -- 吃蛋糕
    if (finish_table["timelimitsign_reward"] ~= 1 and ActivityConfigUtil.isActivityOpen("timelimitsign") and TimeUtil.getSvrTimeByOffset()>TimeUtil.getIntervalByTime("060000")) then
        actionArray:addObject(CCCallFunc:create(timelimitsign_reward))
        actionArray:addObject(dely)
    end
    -- 隆中对
    if (finish_table["lzquiz_getUserInfo"] ~= 1 and isDoubleTime()) then
        actionArray:addObject(CCCallFunc:create(lzquiz_getUserInfo))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 普通试炼塔重置
    if (finish_table["tower_resetTower1"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(tower_resetTower1))
        actionArray:addObject(dely)
    end
    -- 普通试炼塔扫荡
    if (finish_table["tower_resetTower1"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(tower_sweep1))
        actionArray:addObject(dely)
    end
    -- 梦魇试炼塔重置
    if (finish_table["tower_resetTower2"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(tower_resetTower2))
        actionArray:addObject(dely)
    end
    -- 梦魇试炼塔扫荡
    if (finish_table["tower_resetTower2"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(tower_sweep2))
        actionArray:addObject(dely)
    end
    -- 城池争夺奖励领取
    if (finish_table["citywar_getReward"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(citywar_getReward))
        actionArray:addObject(dely)
    end
    -- 攻城副本（只打一次），如果已通关则领奖
    if (finish_table["guildcopy_attack"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(guildcopy_attack))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    --攻城boss购买次数
    if (finish_table["guildcopy_buyBoss"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(guildcopy_buyBoss))
        actionArray:addObject(dely)
    end
    --攻城boss扫荡
    if (finish_table["guildcopy_attackBoss"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(guildcopy_attackBoss))
        actionArray:addObject(dely)
    end
    -- 首页红颜经验领取
    actionArray:addObject(CCCallFunc:create(herobeauty_ecvSettleReward))
    actionArray:addObject(dely)
    -- 月卡领奖
    if (finish_table["monthlycard_getDailyReward1"] ~= 1 or 
        finish_table["monthlycard_getDailyReward2"] ~= 1 or 
        finish_table["monthlycard_getDailyReward3"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(monthlycard_getDailyReward))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 皇陵寻宝
    if (finish_table["robtomb_rob"] ~= 1 and ActivityConfigUtil.isActivityOpen("robTomb")) then
        actionArray:addObject(CCCallFunc:create(robtomb_rob))
        actionArray:addObject(dely)
    end
    -- 邸报签到
    if (finish_table["web_dibao"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(web_dibao))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 副本基金
    if (finish_table["copyfund_gainReward"] ~= 1 and ActivityConfigUtil.isActivityOpen("copyFund")) then
        actionArray:addObject(CCCallFunc:create(copyfund_gainReward))
        actionArray:addObject(dely)
    end
    -- 成长基金
    if (finish_table["limittimegift_gainReward"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(limittimegift_gainReward))
        actionArray:addObject(dely)
    end
    -- 领取vip每日奖励
    if (finish_table["vipbonus_fetchVipBonus"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(vipbonus_fetchVipBonus))
        actionArray:addObject(dely)
    end
    -- 月签
    if (finish_table["sign_gainMonthSignReward"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(sign_gainMonthSignReward))
        actionArray:addObject(dely)
    end
    -- 积分签到
    if (finish_table["dayrecharge_receiveReward"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(dayrecharge_receiveReward))
        actionArray:addObject(dely)
    end
    -- 迎财神
    if (finish_table["getrich_buy"] ~= 1 and ActivityConfigUtil.isActivityOpen("getrich")) then
        actionArray:addObject(CCCallFunc:create(getrich_buy))
        actionArray:addObject(dely)
    end
    -- 累积登录
    if (finish_table["signactivity_getSignactivityInfo"] ~= 1 and ActivityConfigUtil.isActivityOpen("signActivity")) then
        actionArray:addObject(CCCallFunc:create(signactivity_getSignactivityInfo))
        actionArray:addObject(dely)
    end
    -- 节日狂欢
    if (finish_table["festivalact_signReward"] ~= 1 and isFestivalActOpen()) then
        actionArray:addObject(CCCallFunc:create(festivalact_signReward))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 幻化修炼
    if (finish_table["worldplace_getInfo"] ~= 1 and TimeUtil.getSvrTimeByOffset()>TimeUtil.getIntervalByTime("060000")) then
        actionArray:addObject(CCCallFunc:create(worldplace_getInfo))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 欢乐签到
    if (finish_table["happysign_gainSignReward"] ~= 1 and ActivityConfigUtil.isActivityOpen("happySign")) then
        actionArray:addObject(CCCallFunc:create(happysign_gainSignReward))
        actionArray:addObject(dely)
    end
    -- 节日盛典
    if (finish_table["annivseven_recvTaskReward"] ~= 1 and ActivityConfigUtil.isActivityOpen("annivSevenTask")) then
        actionArray:addObject(CCCallFunc:create(annivseven_recvTaskReward))
        actionArray:addObject(dely)
    end
    -- 跨服排位领奖
    if (finish_table["worldrank_recvDailyReward"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(worldrank_recvDailyReward))
        actionArray:addObject(dely)
    end
    -- 国战领奖
    if (finish_table["countrywarinner_worship"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(countrywarinner_worship))
        actionArray:addObject(dely)
    end
    -- 逐鹿中原膜拜
    if (finish_table["throne_worship"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(throne_worship))
        actionArray:addObject(dely)
    end
    -- 争霸天下膜拜
    if (finish_table["guildpoint_worship"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(guildpoint_worship))
        actionArray:addObject(dely)
    end
    -- 三国激斗膜拜
    if (finish_table["worldteam_worship"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(worldteam_worship))
        actionArray:addObject(dely)
    end
    -- 跨服比武膜拜
    if (finish_table["worldcompete_worship"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(worldcompete_worship))
        actionArray:addObject(dely)
    end
    -- 军机大厅扫荡
    if (finish_table["start_copyteam_atkWithOfflineHelp"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(start_copyteam_atkWithOfflineHelp))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 悬赏榜领奖
    if (finish_table["mission_receiveDayReward"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(mission_receiveDayReward))
        actionArray:addObject(dely)
    end
    -- 七星台抽卡
    if (finish_table["sevenslottery_lottery"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(sevenslottery_lottery))
        actionArray:addObject(dely)
    end
    -- 神器台抽卡
    if (finish_table["godbless_bless"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(godbless_bless))
        actionArray:addObject(dely)
    end
    -- 普通名将抽卡
    if (finish_table["forfmhero_draw"] ~= 1 and TimeUtil.getSvrTimeByOffset()<TimeUtil.getIntervalByTime("220000")) then
        actionArray:addObject(CCCallFunc:create(forfmhero_draw))
        actionArray:addObject(dely)
    end
    -- 高级名将抽卡
    if (finish_table["forfmherobt_draw"] ~= 1 and TimeUtil.getSvrTimeByOffset()<TimeUtil.getIntervalByTime("220000")) then
        actionArray:addObject(CCCallFunc:create(forfmherobt_draw))
        actionArray:addObject(dely)
    end
    -- 后军台抽卡
    if (finish_table["houjunfactory_lottery"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(houjunfactory_lottery))
        actionArray:addObject(dely)
    end
    -- 铜雀台抽卡
    if (finish_table["tongque_lottery"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(tongque_lottery))
        actionArray:addObject(dely)
    end
    -- 军团贡献
    if (finish_table["guild_contribute"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(guild_contribute))
        actionArray:addObject(dely)
    end
    -- 军团粮草
    if (finish_table["guild_quickHarvest"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(guild_quickHarvest))
        actionArray:addObject(dely)
    end
    require "db/DB_Legion_feast"
    -- 关公殿免费参拜
    if (finish_table["guild_reward_free"] ~= 1 and TimeUtil.getSvrTimeByOffset() > TimeUtil.getIntervalByTime(tonumber(DB_Legion_feast.getDataById(1).beginTime))) then
        actionArray:addObject(CCCallFunc:create(guild_reward_free))
        actionArray:addObject(dely)
    end
    -- 关公殿金币参拜
    if (finish_table["guild_reward_gold"] ~= 1 and TimeUtil.getSvrTimeByOffset() > TimeUtil.getIntervalByTime(tonumber(DB_Legion_feast.getDataById(1).beginTime))) then
        actionArray:addObject(CCCallFunc:create(guild_reward_gold))
        actionArray:addObject(dely)
    end
    -- 跨服军团贡献和祈福
    if (finish_table["worldguild_contribute"] ~= 1 or finish_table["worldguild_reward"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(worldguild_contribute))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 小游戏第一关胜利一次
    if (finish_table["minigame_gainReward"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(minigame_gainReward))
        actionArray:addObject(dely)
    end
    -- 攻打摇钱树
    if (finish_table["acopy_atkGoldTree"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(acopy_atkGoldTree))
        actionArray:addObject(dely)
    end
    -- 经验宝物扫荡
    if (finish_table["acopy_sweep1"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(acopy_sweep1))
        actionArray:addObject(dely)
    end
    -- 经验熊猫扫荡?未开启时未过滤
    if (finish_table["acopy_sweep2"] ~= 1 and CopyUtil.isHeroExpCopyOpen()) then
        actionArray:addObject(CCCallFunc:create(acopy_sweep2))
        actionArray:addObject(dely)
    end
    -- 经验副本扫荡
    if (finish_table["acopy_sweep3"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(acopy_sweep3))
        actionArray:addObject(dely)
    end
    -- 天命副本扫荡
    if (finish_table["acopy_sweep4"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(acopy_sweep4))
        actionArray:addObject(dely)
    end
    -- 战魂副本扫荡
    if (finish_table["acopy_sweep5"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(acopy_sweep5))
        actionArray:addObject(dely)
    end
    -- 星魂副本扫荡
    if (finish_table["gcopy_sweep"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(gcopy_sweep))
        actionArray:addObject(dely)
    end
    -- 放三令牌副本扫荡
    if (finish_table["warorder_getInfo"] ~= 1 and ActivityConfigUtil.isActivityOpen("warOrder")) then
        actionArray:addObject(CCCallFunc:create(warorder_getInfo))
        actionArray:addObject(dely)
    end
    -- 占星台
    if (finish_table["divine_oneClickDivine"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(divine_oneClickDivine))
        actionArray:addObject(dely)
    end
    -- 占星台领奖
    if (finish_table["divine_drawPrizeAll"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(divine_drawPrizeAll))
        actionArray:addObject(dely)
    end
    --宠物一键领取
    actionArray:addObject(CCCallFunc:create(pet_collectAllProduction))
    actionArray:addObject(dely)
    -- 好友一键赠送体力
    if (finish_table["friend_oneKeyLoe"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(friend_oneKeyLoe))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 水月之境水月副本扫荡
    if (finish_table["moon_sweep1"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(moon_sweep1))
        actionArray:addObject(dely)
    end
    -- 水月之境梦魇副本购买1次
    if (finish_table["moon_addAttackNum2"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(moon_addAttackNum2))
        actionArray:addObject(dely)
    end
    -- 水月之境梦魇副本扫荡
    if (finish_table["moon_sweep2"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(moon_sweep2))
        actionArray:addObject(dely)
    end
    -- 道具商店购买1个体力丹
    if (finish_table["shop_buyGoods1"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(shop_buyGoods1))
        actionArray:addObject(dely)
    end
    -- 道具商店购买1个耐力丹
    if (finish_table["shop_buyGoods2"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(shop_buyGoods2))
        actionArray:addObject(dely)
    end
    -- 道具商店购买666礼包
    if (finish_table["shop_buyGoods18"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(shop_buyGoods18))
        actionArray:addObject(dely)
    end
    -- 酒馆良将招募
    if (finish_table["shop_silverRecruit"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(shop_silverRecruit))
        actionArray:addObject(dely)
    end
    -- 酒馆神将招募
    if (finish_table["shop_goldRecruit"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(shop_goldRecruit))
        actionArray:addObject(dely)
    end
    -- 限时神将招募
    require "script/ui/login/ServerList"
    if (finish_table["heroshop_getMyShopInfo"] ~= 1 and 
    TimeUtil.getSvrTimeByOffset() >= ActiveCache.getHeroShopStartTime() and 
    TimeUtil.getSvrTimeByOffset() <= ActiveCache.getHeroShopEndTime() and 
    ActiveCache.getHeroShopOpenTime() >= tonumber(ServerList.getSelectServerInfo().openDateTime)) then
        actionArray:addObject(CCCallFunc:create(heroshop_getMyShopInfo))
        actionArray:addObject(dely)
    end
    -- 猎魂1000w银币（不留五星魂）
    if (finish_table["hunt_rapidHunt"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(hunt_rapidHunt))
        actionArray:addObject(dely)
    end
    -- 每日签到
    if (finish_table["sign_gainNormalSignReward"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(sign_gainNormalSignReward))
        actionArray:addObject(dely)
    end
    -- 主角学习技能
    if (finish_table["star_quickDraw"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(star_quickDraw))
        actionArray:addObject(dely)
    end
    -- 寻龙探宝
    if (finish_table["dragon_trial"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(dragon_trial))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 神兽试炼购买次数
    if (finish_table["magicpetcopy_buyAtkNum"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(magicpetcopy_buyAtkNum))
        actionArray:addObject(dely)
    end
    -- 神兽试炼
    if (finish_table["magicpetcopy_atkCopy"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(magicpetcopy_atkCopy))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 名将突围购买次数
    if (finish_table["sortie_buyAtkNum"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(sortie_buyAtkNum))
        actionArray:addObject(dely)
    end
    -- 名将突围
    if (finish_table["sortie_getInfo"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(sortie_getInfo))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 符印商店天工宝箱
    if (finish_table["moon_buyBox"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(moon_buyBox))
        actionArray:addObject(dely)
    end
    -- 符印商店天工宝箱
    if (finish_table["godtower_buyNum"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(godtower_buyNum))
        actionArray:addObject(dely)
    end
    -- 通天塔
    if (finish_table["godtower_search"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(godtower_search))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 精英副本
    if (finish_table["ecopy_sweep"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(ecopy_sweep))
        actionArray:addObject(dely)
    end
    -- 将士送礼
    if (finish_table["star_addFavorByAllGifts"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(star_addFavorByAllGifts))
        actionArray:addObject(dely)
    end
    -- 列传副本
    if (finish_table["biography_atkCopy"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(biography_atkCopy))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 竞技场挑战
    if (finish_table["arena_challenge"] ~= 1 and 
    (TimeUtil.getSvrTimeByOffset()<TimeUtil.getIntervalByTime("220000") or 
    TimeUtil.getSvrTimeByOffset()>TimeUtil.getIntervalByTime("223000"))) then
        actionArray:addObject(CCCallFunc:create(arena_challenge))
        actionArray:addObject(dely)
    end
    -- 夺宝
    if (finish_table["fragseize_oneKeySeize"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(fragseize_oneKeySeize))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 藏书阁寻书
    if (finish_table["biography_roll"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(biography_roll))
        actionArray:addObject(dely)
    end
    -- 积分轮盘
    local wheelStartTime = ActivityConfigUtil.getDataByKey("roulette").start_time
    local wheelDay = nil
    if(table.count(ActivityConfigUtil.getDataByKey("roulette").data)>0)then
        wheelDay = ActivityConfigUtil.getDataByKey("roulette").data[1].wheelopentime -- 积分轮盘天数
    end
    if (finish_table["roulette_rollRoulette"] ~= 1 and 
        wheelDay ~= nil and 
        TimeUtil.getDifferDay(wheelStartTime) < tonumber(wheelDay) and 
        TimeUtil.getDifferDay(wheelStartTime) >= 0) then
        actionArray:addObject(CCCallFunc:create(roulette_rollRoulette))
        actionArray:addObject(dely)
    end
    -- 节日回馈(气球)签到
    if (finish_table["anniveleven_recvSignReward"] ~= 1 and ActivityConfigUtil.isActivityOpen("annivElevenSign")) then
        actionArray:addObject(CCCallFunc:create(anniveleven_recvSignReward))
        actionArray:addObject(dely)
    end
    -- 补给卡
    if (finish_table["directsubsidy_gainTaskReward"] ~= 1 and ActivityConfigUtil.isActivityOpen("directSubsidyCard")) then
        actionArray:addObject(CCCallFunc:create(directsubsidy_gainTaskReward))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 助力卡
    if (finish_table["directassist_gainTaskReward"] ~= 1 and ActivityConfigUtil.isActivityOpen("directAssitCard")) then
        actionArray:addObject(CCCallFunc:create(directassist_gainTaskReward))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 直购战令
    if (finish_table["directwarorder_gainReward"] ~= 1 and ActivityConfigUtil.isActivityOpen("directWarOrder")) then
        actionArray:addObject(CCCallFunc:create(directwarorder_gainReward))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 军团活跃宝箱
    if (finish_table["guild_rewardGuildActive"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(guild_rewardGuildActive))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 好友耐力领取
    if (finish_table["friend_unreceiveLoveList"] ~= 1) then
        actionArray:addObject(CCCallFunc:create(friend_unreceiveLoveList))
        actionArray:addObject(dely)
    end
    -- 节日狂欢点将台任务
    if (finish_table["festivalActReward_DianJiangTai"] ~= 1 and isFestivalActOpen() and default_value["festivalActReward_DianJiangTai"]==1) then
        actionArray:addObject(CCCallFunc:create(festivalActReward_DianJiangTai))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 过关斩将
    if (finish_table["pass_enter"] ~= 1 and TimeUtil.getSvrTimeByOffset()>TimeUtil.getIntervalByTime("040000")) then
        actionArray:addObject(CCCallFunc:create(pass_enter))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    -- 贮金
    if (finish_table["zhujin"] ~= 1 and ActivityConfigUtil.isActivityOpen("annivSixth")) then
        actionArray:addObject(CCCallFunc:create(zhujin))
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
        actionArray:addObject(dely)
    end
    --更新体耐力，金币数量等信息
    actionArray:addObject(CCCallFunc:create(updateUserInfo))
    actionArray:addObject(dely)
    -- 扫荡结束提示
    actionArray:addObject(CCCallFunc:create(sweepEnd))
    mainSeqAct = CCSequence:create(actionArray)
    _bgLayer:runAction(mainSeqAct)
    showTip("开始一键扫荡")
end
